Opauth is a multi-provider authentication framework for PHP, inspired by OmniAuth for Ruby.
Opauth enables PHP applications to perform user authentication across different providers with much ease & simplicity.
Opauth interfaces between authentication providers' API and your PHP applications through strategies. Strategies available for Opauth include Facebook, Google, Twitter, OpenID, and more.
Visit http://opauth.org for a quick demo.
Opauth on GitHub: uzyn/opauth
Opauth as a Composer package: opauth/opauth
Opauth is made even easier to be implemented on CakePHP applications through Opauth CakePHP plugin (download).
Quick table of contents:
- How to use this plugin (long and thorough)
- A quick sample app (pre-configured CakePHP app, with screenshots)
-
Download Opauth CakePHP plugin and place it at your CakePHP Plugin directory.
Or via Git:
AssumingAPP
is the directory where your CakePHP app resides, it's usuallyapp/
from the base of CakePHP.cd APP/Plugin git clone git://github.com/uzyn/cakephp-opauth.git Opauth cd Opauth git submodule init git submodule update
-
Add this line to the bottom of your app's
Config/bootstrap.php
:<?php CakePlugin::load('Opauth', array('routes' => true, 'bootstrap' => true));
Overwrite any Opauth configurations you want after the above line.
-
Load strategies onto
Strategy/
directory.Append configuration for strategies at your app's
Config/bootstrap.php
as follows:<?php CakePlugin::load('Opauth', array('routes' => true, 'bootstrap' => true)); // Using Facebook strategy as an example Configure::write('Opauth.Strategy.Facebook', array( 'app_id' => 'YOUR FACEBOOK APP ID', 'app_secret' => 'YOUR FACEBOOK APP SECRET' ));
-
Go to
http://path_to_your_cake_app/auth/facebook
to authenticate with Facebook, and similarly for other strategies that you have loaded. -
After validation, user will be redirected to
Router::url('/opauth-complete')
with validated auth response data retrievable available at$this->data
.To route a controller to handle the response, at your app's
Config/routes.php
, add a connector, for example:<?php Router::connect( '/opauth-complete/*', array('controller' => 'users', 'action' => 'opauth_complete') );
You can then work with the authentication data at, say
APP/Controller/UsersController.php
as follows:<?php // APP/Controller/UsersController.php: class UsersController extends AppController { public function opauth_complete() { debug($this->data); } }
Note that this CakePHP Opauth plugin already does auth response validation for you with its results available as a boolean value at
$this->data['validated']
.
###How about a sample?
Sure. Simply download this CakePHP app and set it up with CakePHP v2.x library.
Once it is set up, you should see:
After authentication, this is what you should be getting:
More instructions on the sample app: https://github.com/uzyn/cakephp-opauth/tree/sample
- Opauth.org for a quick Opauth demo.
- Documentations on Opauth
- Contribute an Opauth strategy
- Discussion group: Google Groups
Feel free to post your questions to the discussion group. This is the primary channel for support. - Issues: Github Issues
- Twitter: @uzyn
- Email me: chua@uzyn.com
- IRC: #opauth on Freenode