2017 © Pedro Peláez
 

luya-module luya-module-apiauth

image

oom/luya-module-apiauth

  • Monday, July 9, 2018
  • by baqianxin
  • Repository
  • 2 Watchers
  • 2 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 62 % Grown

The README.md

Api Module

Build Status, (*1)

An oauth module for LUYA Api users., (*2)

Installation

Install the module trough composer, (*3)

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:, (*4)

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:, (*5)

    'components' => [

        //...
        'user' => [
            'identityClass' => 'oom\api\models\APIAuthUser',
            'enableAutoLogin' => true,
            'enableSession' => false,
            'loginUrl' => null,
        ],
        'urlManager' => [
            'rules' => [
                ['class' => 'yii\rest\UrlRule', 'controller' => 'api/user'],
            ],
        ],
        // ...   
    ]   

Example usage

  1. Insert the test user: http://your.domain/api/sign/signup-test
  2. Send a post request to http://your.domain/api/sign/token with app_key and app_secret data in order to get the access token.

Step 2, (*6)

  1. Test Api with the created access token http://your.domain/api/user/rules?token=ACCESS_TOKEN_FROM_TOKEN_REQUEST

Step 3, (*7)

The Versions