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


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?


in controller behaviors function


                    'actions' => ['index'],

                    'allow' => true,

                    'roles' => [



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.