Role-Based permission management is a simple implementation of RBAC. rbac role permission management _ PHP Tutorial

Source: Internet
Author: User
RBAC is a simple implementation of role-based permission management and rbac role permission management. RBAC is a simple implementation of role-based permission management. rbac role permission management 1. what is permission management? permission management is a subdivision of background functions, role-Based permission management and RBAC role permission management.

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’);

}

Http://www.bkjia.com/PHPjc/1001455.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1001455.htmlTechArticleRBAC role-based permission management based on the simple implementation, rbac role permission management 1, what is permission management, permission management is the subdivision of the background functions, and different staff division...

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.