RBAC creates general WEB permissions and rbacweb Permissions

Source: Internet
Author: User

RBAC creates general WEB permissions and rbacweb Permissions

 

 

 

 

RBAC does not need to assign permissions to a single user. It only needs to point to the corresponding role and has the corresponding permissions. It is convenient to assign and revoke permissions.

Five relationships correspond to five tables

Design of five tables

1 create table 'user' (2 'id' int (11) unsigned not null AUTO_INCREMENT, 3 'name' varchar (20) not null default ''comment' name ', 4 'email 'varchar (30) not null default ''' COMMENT 'mailbox ', 5' is _ admin' tinyint (1) not null default '0' comment' is super administrator 1 0 indicates NOT ', 6 'status' tinyint (1) not null default '1' comment' status 1: valid 0: Invalid ', 7' updated _ time' timestamp not null default '2017-00-00 00:00:00 'comment' last update time ', 8 'created _ time' timestamp not null default '2017-00-00 00:00:00 'comment' insertion time', 9 primary key ('id '), 10 KEY 'idx _ e-mail '('email') 11) ENGINE = InnoDB default charset = utf8 COMMENT = 'user table '; 12 13 create table 'role' (14 'id' int (11) unsigned not null AUTO_INCREMENT, 15 'name' varchar (50) not null default ''comment' role name ', 16 'status' tinyint (1) not null default '1' comment' status 1: Valid 0: Invalid ', 17 'updated _ time' timestamp not null default '2017-00-00 00:00:00 'comment' last update time ', 18 'created _ time' timestamp not null default '2017-00-00 00:00:00 'comment' insertion time', 19 primary key ('id') 20) ENGINE = InnoDB default charset = utf8 COMMENT = 'Role table'; 21 22 create table 'user _ role' (23 'id' int (11) unsigned not null AUTO_INCREMENT, 24 'uid' int (11) not null default '0' COMMENT 'user id', 25' role _ id' int (11) not null default '0' COMMENT 'Role id', 26 'created _ time' timestamp not null default '2017-00-00 00:00:00 'comment' insertion time ', 27 primary key ('id'), 28 KEY 'idx _ uid' ('uid') 29) ENGINE = InnoDB default charset = utf8 COMMENT = 'user role table '; 30 31 create table 'access' (32 'id' int (11) unsigned not null AUTO_INCREMENT, 33 'title' varchar (50) not null default ''comment' permission name ', 34 'urls' varchar (1000) not null default '''comment' json array ', 35 'status' tinyint (1) not null default '1' comment' status 1: valid 0: Invalid ', 36 'updated _ time' timestamp not null default '2017-00-00 00:00:00 'comment' last update time ', 37 'created _ time' timestamp not null default '2017-00-00 00:00:00 'comment' insertion time', 38 primary key ('id') 39) ENGINE = InnoDB default charset = utf8 COMMENT = 'permission details table'; 40 41 create table 'Role _ Access' (42 'id' int (11) unsigned not null AUTO_INCREMENT, 43 'Role _ id' int (11) not null default '0' COMMENT 'Role id', 44 'Access _ id' int (11) not null default '0' comment' permission id', 45 'created _ time' timestamp not null default '2017-00-00 00:00:00 'comment' insertion time ', 46 primary key ('id'), 47 KEY 'idx _ role_id '('Role _ id') 48) ENGINE = InnoDB default charset = utf8 COMMENT = 'Role permission table '; 49 50 create table 'app _ access_log '(51 'id' int (11) not null AUTO_INCREMENT, 52 'uid' bigint (20) not null default '0' COMMENT 'brand uid', 53 'target _ url' varchar (255) not null default ''comment' access url ', 54 'query _ params 'longtext not null comment 'get and post parameters', 55'ua 'varchar (255) not null default ''comment' ACCESS ua ', 56 'IP' varchar (32) not null default ''' COMMENT 'Access ip', 57 'note' varchar (1000) not null default ''comment 'json format COMMENT field ', 58 'created _ time' timestamp not null default CURRENT_TIMESTAMP, 59 primary key ('id'), 60 KEY 'idx _ uid' ('uid') 61) ENGINE = InnoDB default charset = utf8 COMMENT = 'user operation record table'; 62 63 64 insert into 'user' ('id', 'name', 'email ', 'Is _ admin', 'status', 'updated _ time', 'created _ Time') 65 VALUES (1, 'Super admin', 'apanly @ 163.com ', 1, 1, '2017-11-15 13:36:30 ', '2017-11-15 13:36:30 ');

Users are associated with roles, and roles are associated with permissions. You can determine roles to manage permissions (which pages cannot be accessed)

 

Permission judgment logic: Obtain the User Role = according to the user ID. If the user is a super administrator, no permission judgment is required, otherwise, the system returns the prompt Page Based on the role's permission =, and obtains the list of accessible links according to the permission =, and determines whether the current operation is in the list =;

 

This article is a video tutorial from MOOC-RBAC for general web management

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.