2017 © Pedro Peláez
 

yii2-extension yii2-wac-auth

Yii2 CompositeAuth with AccessControl integration.

image

matrozov/yii2-wac-auth

Yii2 CompositeAuth with AccessControl integration.

  • Saturday, April 14, 2018
  • by matrozov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 167 % Grown

The README.md

yii2-auth-wac

Yii2 CompositeAuth with AccessControl integration., (*1)

By default, AuthMethod checks only the internal "optional" property to test whether it is possible to get into this action without authorization. You should duplicate the access rules in AuthMethod and AccessControl. WacAuth allows you to automatically check the guest access rules in AccessControl when AuthMethod is authorized., (*2)

Installation

Either run, (*3)

composer require --prefer-dist matrozov/yii2-wac-auth, (*4)

Usage example

Before:

$behaviors['authenticator'] = [
    'class' => HttpBearerAuth::className(),
    'optional' => ['index']
];

$behaviors['access'] = [
    'class' => AccessControl::className(),
    'only' => ['index'],
    'rules' => [
        [
            'allow' => true,
            'actions' => ['index'],
            'roles' => ['?'],
        ],
    ],
];

You specify the "optional" property and roles="?" at the same time for your action "index"., (*5)

After:

$behaviors['authenticator'] = [
    'class' => WacAuth::className(),
    'authMethods' => [
        HttpBearerAuth::className()
    ]
];

$behaviors['access'] = [
    'class' => AccessControl::className(),
    'only' => ['index'],
    'rules' => [
        [
            'allow' => true,
            'actions' => ['index'],
            'roles' => ['?'],
        ],
    ],
];

You wrap HttpBearerAuth in WacAuth and now it automatically takes into account roles="?" in AccessControl., (*6)

WacAuth and CompositeAuth

Since WacAuth is the successor of CompositeAuth, you can use it in all similar cases for a combination of authorization methods., (*7)

The Versions

14/04 2018

dev-master

9999999-dev https://github.com/matrozov/yii2-wac-auth

Yii2 CompositeAuth with AccessControl integration.

  Sources   Download

MIT

The Requires

 

by Matrozov Oleg

authorization yii2 access-control

14/04 2018

1.0.5

1.0.5.0 https://github.com/matrozov/yii2-wac-auth

Yii2 CompositeAuth with AccessControl integration.

  Sources   Download

MIT

The Requires

 

by Matrozov Oleg

authorization yii2 access-control