PHP code example of macfly / yii2-remote-user-rbac

1. Go to this page and download the library: Download macfly/yii2-remote-user-rbac library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

macfly / yii2-remote-user-rbac example snippets


  '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',
#       ],
      ],
      ................
  ],

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

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

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

php composer.phar