matrozov/yii2-wac-auth
最新稳定版本:1.0.5
Composer 安装命令:
composer require matrozov/yii2-wac-auth
包简介
Yii2 CompositeAuth with AccessControl integration.
README 文档
README
Yii2 CompositeAuth with AccessControl integration.
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.
Installation
Either run
composer require --prefer-dist matrozov/yii2-wac-auth
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".
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.
WacAuth and CompositeAuth
Since WacAuth is the successor of CompositeAuth, you can use it in all similar cases for a combination of authorization methods.
统计信息
- 总下载量: 2.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-14