Yii2 RBAC each time you go to a method to verify that the user has the controller and action permissions? If it is configured then how to configure?
Reply content:
Yii2 RBAC each time you go to a method to verify that the user has the controller and action permissions? If it is configured then how to configure?
Yii\filters\accessrule::matchcalllback. Note the passed parameter $rule, $action
[ 'actions' => ['special-callback'], 'allow' => true, 'matchCallback' => function ($rule, $action) { # write arbitrary access check logic # permission = (rule [xxoo] action) # return user->can(permission); }]
Or use the following method, see Yii2-admin
return [ 'components' => [ 'authManager' => [ 'class' => 'yii\rbac\PhpManager', // or use 'yii\rbac\DbManager' ] ], 'as access' => [ 'class' => 'mdm\admin\components\AccessControl', ],];
AccessControl support for configuring role
For example:
[ 'actions' => ['edit'], 'allow' => true, 'roles' => ['@', 'author'],],