I am using Yii2 Rbac and I am familiar getting permissions, roles etc for a specific user.
Now - to manage Permissions I would like to use it the opposite way - to find all users that a specific permission is linked to. Either direct assignment or assigment through another permissin or Role.
I Have gone through many Rbac methods but have not found a suitable way to get this out of the Rbac components.
Any ideas are appreciated.
P.S. Thank you for Yii
You are right. It looks impossible to get users by permission at a shot.
And, I’m afraid it’s not very easy to implement it on your own, since retrieving parent items is not supported while getting child items is easy with getChildren() method.
Thank you softark!
This is what I was afraid of.
Though it’s for Role (not for Permission), getUserIdsByRole() was sufficient for me when I wanted to show which users are granted a specific right in my RBAC management web UI.
It may be controversial, but I think it would be better not to show/manage Permissions in an RBAC management web UI. They are too fine-grained for non-tech users. And tech users(or developers) would not want them to be managed through web UI since it will make it harder to maintain the RBAC structure in a developer oriented fashion … I’d rather manage my RBAC structure using migration.
I’ve come to the same conclusion as well. UI for assigning roles, migrations for RBAC hierarchy itself.