ukatama/cakephp3_opauthlogin
最新稳定版本:v0.1alpha3
Composer 安装命令:
composer require ukatama/cakephp3_opauthlogin
包简介
Authentication plugin by Opauth for CakePHP 3.0.
README 文档
README
Requirements
- CakePHP 3.0.0 or greater.
- Opauth 0.4.3 or greater.
- Opauth Strategies.
Installation
- Install cakephp3_opauthlogin, Opauth and Opauth Strategies with composer.
Example:
"require": { "php": ">=5.4.16", "mobiledetect/mobiledetectlib": "2.*", "cakephp/cakephp": "3.0.*-dev", "ukatama/cakephp3_opauthlogin": "*", "opauth/opauth": "*", "opauth/twitter": "*" }
- Load the plugin
Plugin::load('OpauthLogin', ['bootstrap' => false, 'routes' => true]);
Usage
-
Install the plugin.
-
Set up config/app.php.
$config = [ /** Other Configurations **/ 'OpauthStrategy' => [ 'Twitter' => [ 'key' => '(Consumer Key)', 'secret' => '(Consumer Secret)' ] ] ];
- Create user table
"auth_provider" and "auth_uid" is required. (ToDo: Field names to be configuratable)
CREATE TABLE `users` ( `id` varchar(45) NOT NULL, `name` varchar(45) NOT NULL, `auth_provider` varchar(45) NOT NULL, `auth_uid` int(11) NOT NULL, `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`) );
- Set up authentication compoonent and OpauthLogin helper.
- Options
-
'fields' (default: [ 'auth_provider' => 'auth_provider', 'auth_uid' => 'auth_uid' ])
Database table field's names.
-
'registrationUrl' (default: null)
Registration page's url redirected when authoriged user is not found. Set null to disable ridirecting.
-
- Options
class AppController extends Controller { public $helpers = ['OpauthLogin.OpauthLogin']; public $components = [ 'Auth' => [ 'loginAction' => [ 'controller' => 'pages', 'action' => 'login' ], 'authenticate' => [ 'OpauthLogin.OpauthLogin' => [ 'fields' => [ 'auth_provider' => 'auth_provider', 'auth_uid' => 'auth_uid', ], 'registrationUrl' => ['plugin' => null, 'controller' => 'users', 'action' => 'add'] ] ] ] ];
- Create login page.
<!-- Make login link as "Login with Twitter". --> <?php echo $this->OpauthLogin->login(__('Login with Twitter'), 'twitter', ['class' => 'btn btn-default']); ?>
- You can use as same as default auth component.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-15