hi,
i am using yii2-admin to implement rbac but
i met some difficulties.
i don’t give a route to a user role. but it can access it.
i don’t know why?
i am using basic yii2
in web.php
'authManager' => [
'class' => 'yii\rbac\DbManager',
'defaultRoles' => ['guest'],
],
'as access' => [
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
'site/*',
'registration/*',
'admin/*',
'some-controller/some-action',
// The actions listed here will be allowed to everyone including guests.
// So, 'admin/*' should not appear here in the production, of course.
// But in the earlier stages of your development, you may probably want to
// add a lot of actions here until you finally completed setting up rbac,
// otherwise you may not even take a first step.
]
],
'modules' => [
'admin' => [
//'rights' => [
'class' => 'mdm\admin\Module',
'controllerMap' => [
'assignment' => [
'class' => 'mdm\admin\controllers\AssignmentController',
'userClassName' => 'app\models\User',
'idField' => 'id_user', // id field of model User
'usernameField' => 'login', // username field of model User
],
],
//],
],
],
im my controller behaviors
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
'only' => ['index','create','update','view'],
'rules' => [
// allow authenticated users
[
'allow' => true,
'roles' => ['@'
/*Users->role_users*/
],
],
// everything else is denied
[
'allow' => true,
'actions' => ['index','view'],
'roles' => ['@'],
],
],
],
];
}