CakePHP plugin for Opauth
Original source https://github.com/uzyn/cakephp-opauth, (*1)
CakePHP 2.x plugin for Opauth., (*2)
Opauth is a multi-provider authentication framework., (*3)
Requirements
CakePHP v2.x
Opauth >= v0.2 (submoduled with this package)
Expandable, (*4)
Installation
-
Use composer.
Add following to the composer.json
file:, (*5)
"require": {
"lubos/opauth": "~1.0"
}
And run php composer.phar update
, (*6)
-
Download Opauth library as a submodule., (*7)
git submodule init
git submodule update
-
Add this line to the bottom of your app's Config/bootstrap.php
:, (*8)
<?php
CakePlugin::load('Opauth', array('routes' => true, 'bootstrap' => true));
Overwrite any Opauth configurations you want after the above line., (*9)
-
Load strategies onto Strategy/
directory., (*10)
Append configuration for strategies at your app's Config/bootstrap.php
as follows:, (*11)
<?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',
'redirect' => '/'
));
-
Go to http://path_to_your_cake_app/auth/facebook
to authenticate with Facebook, and similarly for other strategies that you have loaded., (*12)
-
After validateion you will be redirected to Opauth.Strategy.Facebook.redirect url, (*13)
Note:
If your CakePHP app does not reside at DocumentRoot (eg. http://localhost
), but at a directory below DocumentRoot (eg. http://localhost/your-cake-app
),
add this line to your app's APP/Config/bootstrap.php
, replacing your-cake-app
with your actual path :, (*14)
<?php // APP/Config/bootstrap.php
Configure::write('Opauth.path', '/your-cake-app/auth/');
Configure::write('Opauth.callback_url', '/your-cake-app/auth/callback');