Induction and Comparison of Three permission Design Schemes

Source: Internet
Author: User

Permission design is a sub-unit in many systems. It mainly controls functions and processes. This article lists several common permission design schemes and describes them. The permission system names are all self-initiated. If this is not the case, please submit it.

1. Hierarchical Permission System
This type of permission system is very common in forums. In such a system, the permissions are arranged in descending order. Each user corresponds to a permission and sets the permission level for this user, before performing an operation, check whether the user's permission level is higher than the permission level required for performing the operation.

In the hierarchical permission system, the basic attributes of the User class of the domain object are as follows:
Id // user id
Name // User name

The basic attributes of the domain object permission class Priviledge are as follows:
Id // permission ID
Userid // user ID with this permission
Level // user's permission level

Level setting example
Level corresponds to executable Functions
0 access
1. Follow up
2. You can create a primary sticker.
3. You can delete a primary sticker.
4. channels can be created.
5. channels can be deleted.
6. View users
7. User Permissions Can be assigned.
8. You can change the user password.
9. Users can be deleted.
...

In use, perform an operation, for example, when creating a primary sticker, first retrieve the user from the Session, and then identify the corresponding permission level by its id, compare it with the level (3) required to create a primary sticker. If it is higher than the level, you can create a primary sticker. Otherwise, the report permission is insufficient.

The hierarchical permission system is easy to use. It is used well in rigid control systems such as forums, but it is not applicable to situations where range permission control is required. In this case, we need a range restriction permission system.

2. Permission Restriction System
The disadvantage of the hierarchical permission system is that the scope of control is too wide. For example, a forum has many sub-forums, and the Sub-Forum moderators can also control the posts of another same-level Sub-Forum, this is obviously unreasonable. In this case, we need to control the moderator's permissions within the first edition. In this case, we need to limit the scope of the permission system. this permission system is common in the project management system.

In the hierarchical permission system, the basic attributes of the User class of the domain object are as follows:
Id // user id
Name // User name

The basic attributes of a Project of the domain object category are as follows:
Id // Project ID
Name // project name

The basic attributes of the domain object permission class Priviledge are as follows:
Id // permission ID
Userid // user ID with this permission
Projectid // The project corresponding to this permission
Level // user's permission level

By introducing the new property projectid, we have made effective restrictions on the scope of permissions. Different projects have invalid permission levels and higher levels, thus limiting the scope of permissions.

3. range limit for a single Permission System
In the above two permission systems, high permissions can naturally execute operations with low permission requirements. In this case, the power is not subdivided and is not reasonable in some cases. For example, even the chairman of the Board cannot directly perform the recruitment tasks of the personnel department, he only has the right of suggestion to stay with the employee. in this case, we need to use a range to limit the single permission system. its typical applications include workflows and OA systems.

The basic attributes of the User class of the domain object in the range-restricted single-permission system are as follows:
Id // user id
Name // User name

The basic attributes of a Project of the domain object category are as follows:
Id // Project ID
Name // project name

The basic attributes of the domain object permission class Priviledge are as follows:
Id // permission ID
Userid // user ID with this permission
Projectid // The project corresponding to this permission
Abilityid // permission control capability id

The basic attributes of the permission control capability of a domain object are as follows:
Id // control capability ID
Item // subitem of control capability

Item setting example
Items correspond to executable Functions
0 read
1 Write
2. Query
3. Delete
...

Through the subdivision of permission capabilities, the accuracy of user permission control is more refined, so that users can have a more precise grasp of functions and processes, more in line with complex occasions.

There are no advantages or disadvantages of the above three permission systems, which are only applicable in different scenarios. The previous ones are rough but easy to operate, while the latter ones are accurate but cumbersome, in actual use, we should select an appropriate permission system based on the actual situation.

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.