mahmoodr786/cakephp-auth0

CakePHP 插件,用于验证 Auth0 JWT 令牌并验证用户。

安装: 21

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:cakephp-plugin

v1.1.0 2017-07-09 15:01 UTC

This package is not auto-updated.

Last update: 2024-09-18 20:48:07 UTC


README

安装

composer require mahmoodr786/cakephp-auth0

在您的 AppController 中加载适配器。将以下代码添加到您的初始化函数中。

$this->loadComponent('Auth', [
        'storage' => 'Memory',
        'authenticate' => [
                'Form' => [
                        'scope' => ['Users.status' => 1],
                ],
                'Mahmoodr786/AuthZero.Auth0' => [
                        'userModel' => 'Users',
                        'scope' => ['Users.status' => 1],
                        'client_id' => 'CLIENT ID HERE',
                        'secret' => 'SECRET HERE',
                        'fields' => [
                                'username' => 'id',
                        ],
                ],
        ],
        'checkAuthIn' => 'Controller.initialize',
]);

就是这样。向您的应用程序发送带有授权 Bearer 您的Auth0JWTToken头部的请求,您应该能够访问应用程序中的用户。

debug($this->Auth->user());

谷歌和Facebook

要使用谷歌和Facebook 登录,请使用 Auth0 设置它,向 Auth0 添加规则,并在数据库中同步用户的凭证。在数据库中的用户表中添加一个名为 external_id 的列,并将从 Auth0 获取的 facebook|12323445 或 google-oauth2|1234567 id 存储在该字段中。这样就完成了。