: This article mainly introduces stone 830 on the beach. if you are interested in PHP tutorials, please refer to it. 1. what is permission management? permission management refers to the subdivision of background functions and the management of Jobs divided by different employees
How RBAC is implemented is managed by limiting the methods of different controllers and controllers.
To implement RBAC, three tables, one user table, one role table, and one permission table are required.
User table:
Id ****** role_id
Role table
Role_id ****** access_ids (record all accessible permission IDs)
Permission table
Access_id
Records the actions of all controllers or controllers.
2. how to control it? just make a judgment in the parent class of the controller or the initialization method of the controller.
$ Role_id = $ _ SESSION ['role _ id'];
$ Role = $ db-> role-> findByPk ($ role_id );
$ Access = $ db-> access-> findAllByPk ($ role ['Access _ id']);
Obtain the controller or controller method to be executed based on the vro class
$ M = current_method (); // Obtain the method to be accessed
If (! In_array ($ m, $ access )){
Redirect ('/index ');
}
The above introduces the stone 830 on the beach, including the content, hope to be helpful to friends who are interested in PHP tutorials.