The simple implementation of RBAC role-based rights management and RBAC role Rights Management
1, what is the rights management, rights management is to the background function of the subdivision, and different staff division of different work management
How RBAC is implemented through the different methods of different controllers and controllers, the implementation of the management.
To implement RBAC requires three tables, a user table, a list of roles, a permission table
User table:
ID ****** role_id
Role table
role_id ****** access_ids (record all accessible permission IDs)
Permission table
access_id
Record action on all controllers or controllers
2, how to control, in the controller's parent class or the method of initialization of the controller can be judged
$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 according to the router class
$m = Current_method ();//Gets the method currently being accessed
if (!in_array ($m, $access)) {
Redirect ('/index ');
}
http://www.bkjia.com/PHPjc/1001455.html www.bkjia.com true http://www.bkjia.com/PHPjc/1001455.html techarticle RBAC is a simple implementation of role-based rights management, RBAC role Rights Management 1, what is rights management, rights Management is the subdivision of the background function, and different staff division ...