A simple implementation of RBAC role-based rights management and RBAC role Rights Management _php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.