B
B
balex7772019-10-09 07:01:30
Yii
balex777, 2019-10-09 07:01:30

I want to write my own AccessControl filter to set access to controller actions from the admin panel, what is the best way to do it?

Please advise. I want to write my own AccessControl filter to set access to controller actions from the admin panel.
The idea is this in the behaviors of each controller, I will pass actions and the name of the controller to my filter, and the filter, based on the settings saved in the file for this controller, will issue access permissions to each Action for the configured roles. Basically, I understand how to do it. But the question is different, in the admin panel in the role settings I want to display all the controllers and their actions in order to configure access control for each action of a specific controller for a specific role. The question is, How elegant is it to define which controllers exist throughout the project and which Actions they have to give them access settings. I know you can check all the classes in the project every time you enter the role settings and select only controllers and look at actions in them, but I think that this is a crutch and there should be another method.
In general, advise how to be or give examples where this is embodied to see?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-10-18
@balex777

So-so task. But there is a ready-made solution that you need) RBAC.
To composer "mdmsoft/yii2-admin": "~2.0"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question