Advanced RBAC - Assign the user role dependent on an id from another table

Hello,

I have a problem that escapes the basic implementation of RBAC where I need help.

The situation is this:

In a project there may be unlimited forums.

A user can have permissions in more than one forum, and the role depends forum.

If the number of forums were defined and limited, I would be enough to create a permission for each forum.

But the number is unlimited, then the RBAC code should involve the id of the forum table.

Has anyone worked with a similar situation and can help me, please?

What is the best choice to code this problem?

Thanks!

in controller behaviors function

[

                    'actions' => ['index'],


                    'allow' => true,


                    'roles' => [


                         Yii::$app->user->identity->roleId 


                    ],

and in component file code like

fetch data from forum table where roleId= $role.

  • you have to create one forumtable to access forum by roleId.