00f100 / cakephp-opauth
Opauth plugin for CakePHP v3.x, allowing simple plug-n-play 3rd-party authentication with CakePHP
Installs: 693
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Type:cakephp-plugin
Requires
- php: >=5.3.0
- cakephp/cakephp: 3.1.5
- opauth/opauth: dev-master
This package is auto-updated.
Last update: 2024-11-18 06:42:56 UTC
README
CakePHP 3.x plugin for Opauth.
Opauth is a multi-provider authentication framework.
Requirements
- CakePHP >= v3.0
- Opauth >= v1.0
Using Composer
You can install CakePHP-Opauth plugin directly from Composer at wouter0100/cakephp-opauth.
How to use
-
Install this plugin using Composer, add
"wouter0100/cakephp-opauth": "*"
to your Composer file and executecomposer update
. -
Add this line to the bottom of your app's
config/bootstrap.php
:Plugin::load('Wouter0100/Opauth', ['routes' => true, 'bootstrap' => true]);
-
Create a
config/opauth.php
file with the URL you wish to use for handeling the authentication data after opauth has run:<?php $config['Opauth']['CompleteURL'] = '/auth/complete';
You may want to add
config/opauth.php
to your gitignore, as the file will contain sensitive information. -
Load strategies using Composer for Opauth 1.0.0.
Append configuration for strategies at your
config/opauth.php
file as follows:// Using Facebook strategy as an example $config['Opauth']['Strategy']['Facebook'] = [ 'app_id' => 'YOUR FACEBOOK APP ID', 'app_secret' => 'YOUR FACEBOOK APP SECRET' ];
-
Go to
/auth/facebook
to authenticate with Facebook, and similarly for other strategies that you have loaded. -
After validation, user will be redirected to
'/auth/complete'
(or whatever you chose in theopauth.php
config file) with validated auth response data retrievable available at$this->response->data
.To route a controller to handle the response, at your app's
config/routes.php
, add a connector, for example:$routes->connect( '/auth/complete', ['controller' => 'Users', 'action' => 'complete'] );
You can then work with the authentication data at, say
src/Controller/UsersController.php
as follows:<?php namespace App\Controller; use App\Controller\AppController; class UsersController extends AppController { public function complete() { debug($this->request->data); } }
Note that this CakePHP Opauth plugin already does auth response validation for you with its results available as a boolean value at
$this->request->data['validated']
.
Issues & questions
- Discussion group: Google Groups
This is the primary channel for support, especially for user questions. - Issues: Github Issues
- Twitter: @wouter0100
- Email me: wouter@wouter0100.nl
- IRC: #opauth on Freenode
Used this plugin in your CakePHP project? Let us know!
License
The MIT License
Copyright © 2012-2015 U-Zyn Chua (http://uzyn.com), further mentained by Wouter van Os (http://wouter0100.nl)