chervand/yii-access-control
AuthManager configuration
Proper authManager component should be configured (CPhpAuthManger or CDbAuthManager), (*1)
CDbAuthManager (Example)
Apply migrations or create DB tables as described in CDbAuthManager documentation., (*2)
...
'components' => [
...
'authManager' => [
'class' => 'CDbAuthManager',
'connectionID' => 'db',
'itemTable' => 'auth_item',
'itemChildTable' => 'auth_item_child',
'assignmentTable' => 'auth_assignment',
'defaultRoles' => ['guest', 'user', 'support', 'moder', 'admin'],
],
...
],
...
Filter configuration
Import a filter in config or in controller, (*3)
...
'import' => [
...
'vendor.chervand.yii-access-control.components.*',
...
],
...
Controller
- exclude - Excluded routes. Will not be filtered.
- message - 403 error message.
class Controller extends CController
{
...
public function filters()
{
return [
...
[
'AccessControlFilter',
'message' => Yii::t('app', 'You are not authorized to perform this action.'),
'exclude' => [
'site/index',
'site/error'
]
],
...
];
}
...
}
Creating Rules
, (*4)