PHPackages                             ikkez/f3-opauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ikkez/f3-opauth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ikkez/f3-opauth
===============

Opauth Plugin for PHP Fat-Free Framework

v1.0.1(7y ago)312.0k6[2 PRs](https://github.com/ikkez/f3-opauth/pulls)1GPL-3.0PHP

Since Aug 26Pushed 2y ago6 watchersCompare

[ Source](https://github.com/ikkez/f3-opauth)[ Packagist](https://packagist.org/packages/ikkez/f3-opauth)[ Docs](https://github.com/ikkez/f3-opauth)[ RSS](/packages/ikkez-f3-opauth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (1)

F3 Opauth Plugin
================

[](#f3-opauth-plugin)

This is a plugin for easy integration of [Opauth](http://opauth.org/) for PHP Fat-Free Framework.

### Installation

[](#installation)

- A: use composer `composer require ikkez/f3-opauth`
- or B: put the opauth folder somewhere into your libs or autoloaded directory, and adjust the autoload path:

```
// adjust the autoloader
$f3->set('AUTOLOAD','lib/opauth/');
```

### Configuration

[](#configuration)

1. You need to **configure** each strategy you want to use on your service. You can find instructions how to do that in each [**strategy folder**](https://github.com/ikkez/f3-opauth/tree/master/lib/opauth/Strategy)'s readme file. Basically you only need to create some OAuth consumer apps on the strategy's provider and add the key/secret credentials to the config file. Google,Facebook,Twitter,and Github are already included here, so you can skip the *Install* part in their readme files. If you need more OAuth providers, check the the [list of strategies](https://github.com/uzyn/opauth/wiki/List-of-strategies).
2. This plugin comes with its own [configuration file](https://github.com/ikkez/f3-opauth/blob/master/lib/opauth/opauth.ini). It's used to provide all strategy configuration to Opauth, as well as some F3 routing settings. You should at least change the *security\_salt* and your favorite strategy keys and secrets.
3. Integrate the authorization into your existing login procedure.

### Basic Usage

[](#basic-usage)

```
// in your index.php
$f3 = \Base::instance();
// load opauth config (allow token resolve)
$f3->config('lib/opauth/opauth.ini', TRUE);

// init with config
$opauth = OpauthBridge::instance($f3->opauth);

// define login handler
$opauth->onSuccess(function($data){
	header('Content-Type: text');
	echo 'User successfully authenticated.'."\n";
	print_r($data['info']);
});

// define error handler
$opauth->onAbort(function($data){
	header('Content-Type: text');
	echo 'Auth request was canceled.'."\n";
	print_r($data);
});

$f3->run();
```

The event handlers can also be callable string:

```
$opauth->onSuccess('\Controller\User->socialLogin');
```

To login, call a strategy, i.e.`http://domain.com/auth/facebook`.

### Application flow

[](#application-flow)

1. Alright, you place a social login button near your regular login form, that send the user to the login strategy, i.e. `http://domain.com/auth/facebook`.
2. When a user authenticated to a provider, the user is send back to a callback-route. The callback checks if the request and auth was valid. Then, when the authorization was successful, the `onSuccess` handler is called and provides you some data from the given strategy.
3. You can use this data to extract a username, access-token, email or what ever suits best for that strategy. Each strategy provides different data, so depending on your application needs, you perhaps should consider to add some fallback mechanisms into your application (i.e. it can happen that you wont get an email from twitter or facebook). You can use this data to find a match in your user database. Depending on the result you can start your login or registration controller.
4. On registration, you might want to save that unique-something from the strategy-auth-data to the user table (email, or `$f3->hash` on multiple fields like username,token,id) - this way you know who has activated a social auth provider and get the chance to load the user based on this.
5. After registration and on login, you probably save an active user session in your controller to memorize your logged in user.
6. When the session is expired or the user need to login again from another device, send him to the auth strategy route again (`auth/facebook` - instant redirect after successful activation on most providers), and now you can find him in your user table with activated social auth and login him in directly.

This is of course just one idea of implementation. Some providers also return tokens for further communication with their 3rd party API (i.e. to fetch more profile data or renew tokens), but that's something this plugin is not going to handle. Have a look at the strategy docs for more information.

### Demo

[](#demo)

- [facebook](http://f3.ikkez.de/auth/facebook)
- [twitter](http://f3.ikkez.de/auth/twitter)
- [google](http://f3.ikkez.de/auth/google)
- [github](http://f3.ikkez.de/auth/github)

License
-------

[](#license)

GPLv3

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 78.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Total

2

Last Release

2567d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84cac52f5889d2bf6e710f2139dfc884824b2d7ce9c48a3bfe90704a94c85722?d=identicon)[ikkez](/maintainers/ikkez)

---

Top Contributors

[![ikkez](https://avatars.githubusercontent.com/u/1177647?v=4)](https://github.com/ikkez "ikkez (11 commits)")[![slavino](https://avatars.githubusercontent.com/u/1584034?v=4)](https://github.com/slavino "slavino (2 commits)")[![kumy](https://avatars.githubusercontent.com/u/176794?v=4)](https://github.com/kumy "kumy (1 commits)")

---

Tags

authenticationfat-free-frameworkopauthauthAuthenticationoauthOPAuthF3fatfree

### Embed Badge

![Health badge](/badges/ikkez-f3-opauth/health.svg)

```
[![Health](https://phpackages.com/badges/ikkez-f3-opauth/health.svg)](https://phpackages.com/packages/ikkez-f3-opauth)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.0M3](/packages/auth0-login)[uzyn/cakephp-opauth

Opauth plugin for CakePHP v2.x, allowing simple plug-n-play 3rd-party authentication with CakePHP

129276.5k](/packages/uzyn-cakephp-opauth)[lorenzoferrarajr/lfj-opauth

LfjOpauth is a Zend Framework 2 module that enables support for many authentication providers through the Opauth framework.

2915.4k](/packages/lorenzoferrarajr-lfj-opauth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
