I have followed some guides to set up rbac in yii 2
I have set up the table added a few user and so on.
RBAC init controller.
class RbacController extends \yii\console\Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
$baseUser = $auth->createRole('base_user');
$auth->add($baseUser);
$support = $auth->createRole('support');
$auth->add($support);
$admin = $auth->createRole('admin');
$auth->add($admin);
$auth->addChild($admin, $baseUser);
$auth->addChild($admin, $support);
$auth->assign($support, 2);
$auth->assign($admin, 1);
}
}
So I have an admin and some user groups.
Now in one of my controllers I have
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'actions' => ['create'],
'roles' => ['admin'],
],
[
'allow' => true,
'actions' => ['index'],
'roles' => ['@'],
],
],
],
];
}
In the 'roles' I would like to put admin. I can't quite work out how to get this to work.
Is it overkill for my project using RBAC, I just want certain groups of users to access certain areas/functions of the site.