An oauth module for LUYA Api users.
Install the module trough composer
composer require oom/luya-module-apiauth:dev-master
In order to add the modules to your project go into the modules section of your config:
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',
// ...
],
];
Enable the user component with the built in ApiAuthUser class and add the REST Url rule:
'components' => [
//...
'user' => [
'identityClass' => 'oom\api\models\APIAuthUser',
'enableAutoLogin' => true,
'enableSession' => false,
'loginUrl' => null,
],
'urlManager' => [
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'api/user'],
],
],
// ...
]
- Insert the test user:
http://your.domain/api/sign/signup-test
- Send a post request to
http://your.domain/api/sign/token
withapp_key
andapp_secret
data in order to get the access token.
- Test Api with the created access token
http://your.domain/api/user/rules?token=ACCESS_TOKEN_FROM_TOKEN_REQUEST