How to design permission control mechanisms in a system (3)

xiaoxiao2021-03-06  66

In the first quarter, I put forward the most primitive demand and defined several interfaces.

In the second section, I refine this demand, designed a data structure and some basic operations, which can meet some low-level needs. In the discussion with Babituo, he gave me some more detailed and reality needs, I would like to further abstract and design. Babituo mentioned "How to control the permissions for dynamically created articles", and some other concepts are very inspiring.

Target: Simple core, simple customization (program or configuration), there is a common template for common situations. Simple modifications can cope with complex demand. Learn Struts.

The first is three basic elements: operator (main), operation (presence), resource (guest).

The operator refers to the body of the action, does not necessarily mean that a specific person, or a group of people, or means a module in the system, which should be unique, with a unique ID value.

Operation refers to the action of the resource, such as opening, display, etc., the same ID value must also have a unique ID value.

Resources refer to objects that are operated, can refer to a single object, such as a menu item; you can also refer to a group of objects, such as a group menu. Of course, this set of menus is also a single object.

Inheritance of operator privileges

The operator's parent's permissions are inherited by the lower level, such as "Xiao Wang" is the employee of the "R & D Center", so unless certain permissions are the use of Xiao Wang forbidden, the R & D center is all permissions, Xiao Wang All. The inheritance here is not the inheritance of the class, but only one inheritance or the relationship of the business.

Entertainment allocation of new resources, such as the operation of the new article

For new articles, the general creator will have all the operation permissions to this article, so I design two classes: News, Newstype and Journalism Articles, NEWS. News categories have only one example: newstype, its children "news a newsa" is an example of "news news". The children here NEWSA did not inherit what features from the father's NEWSTYPE. "News Class" has an interface init (), indicating that every initialization operation is performed every generation, where we can define the automatic execution of the instance to the creator. Of course, this requires custom programs.

New operator's permission assignment

This is similar to the permission assignment of the new resource. For an operator class, there will be interface init (), which describes the operations you want to create when you create a new instance.

Combination of operation

For example, for an article view, modify, delete an operation is collectively referred to as an article on an article, with permissions to an article management operation, also have permission to view, modify, and delete this article.

转载请注明原文地址:https://www.9cbs.com/read-90665.html

New Post(0)