2017 © Pedro Peláez
 

yii2-extension yii2-remote-user-rbac

Yii2 module to get user and rbac information from a remote api

image

macfly/yii2-remote-user-rbac

Yii2 module to get user and rbac information from a remote api

  • Thursday, October 12, 2017
  • by Macfly
  • Repository
  • 1 Watchers
  • 0 Stars
  • 877 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 20 % Grown

The README.md

yii2-remote-user-rbac

Yii2 User and Rbac provider from another Yii2 instance for sso or cenralized way to manage user and role., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist "macfly/yii2-remote-user-rbac" "*"

or add, (*4)

"macfly/yii2-remote-user-rbac": "*"

to the require section of your composer.json file., (*5)

Configure

NOTE: Make sure that you don't have user component configuration in your config files., (*6)

Configure config/web.php as follows, (*7)

  'components' => [
    ................
    'authClientCollection' => [
      'class'   => \yii\authclient\Collection::className(),
      'clients' => [
        'oauth2' => [
          'class'           => 'macfly\authclient\OAuth2',
          'authUrl'         => 'http://127.0.0.1:8888/oauth2/authorize',
          'tokenUrl'        => 'http://127.0.0.1:8888/oauth2/token',
          'apiBaseUrl'      => 'http://127.0.0.1:8888/oauth2',
          'clientId'        => 'testclient',
          'clientSecret'    => 'testpass',
          'requestOptions'  => [
            'sslVerifyPeer' => false,
            'sslVerifyPeerName' => false,
          ],
        ],
      ],
    ],
  ................
  'modules' => [
      ................
      'user'  => [
       'class'       => 'macfly\user\client\Module',
             'cacheDuration' => 3600,
       'authclient'  => 'oauth2',
       'rememberFor' => 1209600, # Session life (default: 1209600)
       'identityUrl' => 'http://127.0.0.1:8888/user/api/identity', # (optional)
       'rbacUrl'     => 'http://127.0.0.1:8888/user/api/rbac',     # (optional)
#            'userComponent' => '',
#      'modelMap'    => [],
#      'remoteModelMap' = [
#         'app\models\User' => 'User',
#       ],
      ],
      ................
  ],

Usage

Authentication with HTTP Bearer token

HttpBearerAuth is an action filter that supports the authentication method based on HTTP Bearer token., (*8)

You may use HttpBearerAuth by attaching it as a behavior to a controller or module, like the following:, (*9)

public function behaviors()
{
    return [
        'authenticator' => [
            'class' => \macfly\user\client\filters\auth\HttpBearerAuth::className(),
        ],
    ];
}

Example of usage on a controller, (*10)

curl --header 'Authorization: Bearer 0205ade34ff0b8dab4489059803add3fc9ba5c47' 'http://127.0.0.1:8888/api/publish'

Authentication with HTTP Basic Authentication

HttpBasicAuth is an action filter that supports the HTTP Basic authentication method., (*11)

You may use HttpBasicAuth by attaching it as a behavior to a controller or module, like the following:, (*12)

public function behaviors()
{
    return [
        'authenticator' => [
            'class' => \macfly\user\client\filters\auth\HttpBasicAuth::className(),
        ],
    ];
}

Example of usage on a controller, (*13)

curl 'http://0205ade34ff0b8dab4489059803add3fc9ba5c47:@127.0.0.1:8888/api/publish'

Authentication with Query Parameter Authentication

QueryParamAuth is an action filter that supports the authentication based on the access token passed through a query parameter., (*14)

You may use QueryParamAuth by attaching it as a behavior to a controller or module, like the following:, (*15)

public function behaviors()
{
    return [
        'authenticator' => [
            'class' => \macfly\user\client\filters\auth\QueryParamAuth::className(),
        ],
    ];
}

Example of usage on a controller, (*16)

curl 'http://127.0.0.1:8888/api/publish?access-token=0205ade34ff0b8dab4489059803add3fc9ba5c47'

The Versions

12/10 2017

dev-master

9999999-dev

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

12/10 2017

0.2.1

0.2.1.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

12/10 2017

0.2.0

0.2.0.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

11/10 2017

0.1.2

0.1.2.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

02/08 2017

0.1.1

0.1.1.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

01/08 2017

0.1.0

0.1.0.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

11/07 2017

0.0.4

0.0.4.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

04/04 2017

0.0.3

0.0.3.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

31/03 2017

0.0.2

0.0.2.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac

31/01 2017

0.0.1

0.0.1.0

Yii2 module to get user and rbac information from a remote api

  Sources   Download

BSD-3-Clause

The Requires

 

by Charles DELFLY

user yii2 rbac