thinkphp RBAC Official website Examples of detailed

Source: Internet
Author: User
Tags table name

Always want to learn RBAC, but also see the official website example, and Baidu, did not find the appropriate tutorial. So you can only study it yourself, take the official website example.

Think_access table

The role is to see whether a group has permission to access a module under the method or access to a module, the table less than a PID field, you can add yourself

Think_node Table, Node table

The role is to all the required modules, modules under the method are added to the management, with this can also be read directly into the background of the navigation

The Name field is the module, the names of the methods, such as the index module, the index method, and so on.

PID, the parent ID of this module or method,

Level, grade, general project name is 1, module is 2, the method is 3

Normal first add project name, PID for 0,level for 1,status must be 1.

Generally have a default index module, the index module has the default index method,

So, insert index,pid as the Id,level for the project name is 2, and then insert index,pid as the module Id,level is 3.

Think_role as a group of tables

Think_user (built, can use another name, remember to change in the configuration file), user table

Think_role_user is the association of user tables and group tables.

Next, create a new indexaction,publicaction,commonaction under Lib

Then copy the official website Rbac example in the config.php in the content to their own projects,

About all the configuration of RBAC

' user_auth_on ' => true,

' User_auth_type ' => 2,//default authentication type 1 login authentication 2 Real Time authentication

' User_auth_key ' => ' authid ',//user authentication session Mark

' Admin_auth_key ' => ' the Administrator ',

' User_auth_model ' => ' user ', or default validation datasheet model, if user table name is not users

' Auth_pwd_encoder ' => ' MD5 ',//user authenticated password encryption method

' User_auth_gateway ' => '/public/login ',//default authentication Gateway

' Not_auth_module ' => ' public ',//default No Authentication module

' Require_auth_module ' => ',//default required authentication module

' Not_auth_action ' => ', no authentication action is required by default

' Require_auth_action ' => ',//default required authentication operation

' guest_auth_on ' => false,//whether to open visitor authorized access

' guest_auth_id ' => 0,//visitor's user ID

' Db_like_fields ' => ' Title|remark ',

' Rbac_role_table ' => ' think_role ',

' Rbac_user_table ' => ' Think_role_user ',

' Rbac_access_table ' => ' think_access ',

' Rbac_node_table ' => ' Think_node ',

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.