Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/uzyn/cakephp-opauth

Opauth plugin for CakePHP v2.x, allowing simple plug-n-play 3rd-party authentication with CakePHP
https://github.com/uzyn/cakephp-opauth

Last synced: 4 days ago
JSON representation

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

Awesome Lists containing this project

README

        

CakePHP plugin for Opauth
=========================

CakePHP 2.x plugin for [Opauth](https://github.com/uzyn/opauth).

Opauth is a multi-provider authentication framework.

Requirements
---------
CakePHP v2.x
Opauth >= v0.2 _(submoduled with this package)_

Using [Composer](http://getcomposer.org/)?
-----------
You can install CakePHP-Opauth plugin directly from Composer at [uzyn/cakephp-opauth](http://packagist.org/packages/uzyn/cakephp-opauth).
It works for Opauth strategies too!

View notes and Composer-enabled plugin code at [composer branch](https://github.com/uzyn/cakephp-opauth/tree/composer).

Tutorial & sample app
----------
Check out [CakePHP bakery](http://bakery.cakephp.org/articles/uzyn/2012/06/25/simple_3rd-party_provider_authentication_with_opauth_plugin) for tutorial and the [sample branch](https://github.com/uzyn/cakephp-opauth/tree/sample) for a quick sample app.

How to use
----------
1. Install this plugin for your CakePHP app.
Assuming `APP` is the directory where your CakePHP app resides, it's usually `app/` from the base of CakePHP.

```bash
cd APP/Plugin
git clone git://github.com/uzyn/cakephp-opauth.git Opauth
```

2. Download Opauth library as a submodule.

```bash
git submodule init
git submodule update
```

3. Add this line to the bottom of your app's `Config/bootstrap.php`:

```php
true, 'bootstrap' => true));
```
Overwrite any Opauth configurations you want after the above line.

4. Load [strategies](https://github.com/uzyn/opauth/wiki/list-of-strategies) onto `Strategy/` directory.

Append configuration for strategies at your app's `Config/bootstrap.php` as follows:
```php
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'
));
```

5. Go to `http://path_to_your_cake_app/auth/facebook` to authenticate with Facebook, and similarly for other strategies that you have loaded.

6. 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
'users', 'action' => 'opauth_complete')
);
```

You can then work with the authentication data at, say `APP/Controller/UsersController.php` as follows:

```php
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']`.

7. _(optional)_ The submoduled Opauth core library may not be of the latest build, to update to the latest:
```bash
git submodule foreach git pull origin master
```

### 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 :

```php
Used this plugin in your CakePHP project? Let us know!

License
---------
The MIT License
Copyright © 2012-2013 U-Zyn Chua (http://uzyn.com)

Package building instructions
--------------
Instructions for making into a nice zipped package for download.

```bash
git checkout master
git submodule update --init --recursive

rm -rf `find . -type d -name .git`

cd ..
mv cakephp-opauth Opauth

zip -mr Opauth-CakePHP-plugin-X.Y.Z.zip Opauth
```

Consultation
---------
U-Zyn Chua is the Principal Consultant at [Zynesis Consulting](http://zynesis.com), specializing in CakePHP.
Looking for PHP web development solutions or consultation? [Drop me a mail](mailto:[email protected]).