oom / luya-module-apiauth
1.0.0
2018-04-23 14:36 UTC
Requires
- luyadev/luya-core: ~1.0.0
- luyadev/luya-module-admin: ~1.1.0
- yiisoft/yii2-queue: ~2.0.0
This package is not auto-updated.
Last update: 2024-09-24 10:07:58 UTC
README
LUYA Api用户的oauth模块。
安装
通过composer安装此模块
composer require oom/luya-module-apiauth:dev-master
为了将模块添加到项目中,请进入配置的模块部分
return [ 'modules' => [ // ... 'api' => [ 'class' => 'oom\api\frontend\Module', 'useAppViewPath' => true, // When enabled the views will be looked up in the @app/views folder, otherwise the views shipped with the module will be used. ], 'apiadmin' => 'oom\api\admin\Module', // ... ], ];
使用内置的ApiAuthUser类启用用户组件,并添加REST URL规则
'components' => [ //... 'user' => [ 'identityClass' => 'oom\api\models\APIAuthUser', 'enableAutoLogin' => true, 'enableSession' => false, 'loginUrl' => null, ], 'urlManager' => [ 'rules' => [ ['class' => 'yii\rest\UrlRule', 'controller' => 'api/user'], ], ], // ... ]
示例用法
- 插入测试用户:
http://your.domain/api/sign/signup-test
- 向
http://your.domain/api/sign/token
发送POST请求,包含app_key
和app_secret
数据,以获取访问令牌。
- 使用创建的访问令牌测试API:
http://your.domain/api/user/rules?token=ACCESS_TOKEN_FROM_TOKEN_REQUEST