oom / luya-module-apiauth
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:luya-module
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: 2025-03-11 12:24:48 UTC
README
An oauth module for LUYA Api users.
Installation
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'], ], ], // ... ]
Example usage
- 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