PhpGACL Chinese manual (8)

Source: Internet
Author: User
PhpGACL (8) name of a permission object the phpGACL system uses a combination of two keywords to uniquely identify each permission object (ARO, AXO, or ACO object) and it is a permission object type. It uniquely identifies a permission object in the form of tuples (permission object type, section, value. The first element of the tuple is the permission object type (ARO, AXO phpGACL Chinese manual (8)
Permission object name

The phpGACL system uses a combination of two keywords to uniquely identify each permission object (ARO, AXO, or ACO object), and it is a permission object type.

It uniquely identifies a permission object in the form of tuples (permission object type, section, value.

The first element of the tuples is the permission object type (ARO, AXO, or ACO ).

The second element of a tuples is called a section, which is a string of the generic class of the user-defined naming permission object. Multiple permission objects can share the same node name. The node name is short but descriptive. it is often used in the selection box on the user interface, so it is not defined too long.

The section is saved in a unit namespace, which is not nested as a group. The section does not do anything in the group/ARO/AXO tree. it is only used to help maintain a large number of permission objects.

The third element of the tuples is the value, which is the name of the permission object defined by the user. The value cannot contain spaces (while the section can ).

The section and value are both case sensitive.

In addition, why do we use strings to identify permission objects instead of seemingly faster integers? the reason is that it is easy to identify, as shown in the following example:

Acl_check ('system', 'login', 'users', 'John _ doe ');

Comparison:
Acl_check (10,210 04, 15,203 04 );
It is easier to understand.

Because the context can clearly understand the type of the permission object we specify, phpGACL (and this document) the permission object type is removed when the permission object name is displayed, and only the "Section> Value" format is used. In API, the "section" and "value" of the permission object must be specified in the function parameters respectively (the permission object type is usually not explicitly specified in the parameter description)

For exampleACOObject section>Value"

  • "Floor> First Floor"
  • "Floor> second floor"
  • "Room> engine room"

For exampleAROObject section>Value"

"Man> John_Smith"

"Person> Cathy_Jones"

"Host> sandbox.something.com"

For exampleAPIUsage:

  • Acl_check (ACO _ section, ACO _value, aro_section, aro_value );

  • Acl_check ('locks', '2nd', 'people', 'John _ Smith ');

Valid instance naming restrictions:

  • "ACO-Frob> Flerg", "ARO-Frob> Flerg" (although the nodes and values are the same, this name is valid, because the namespace is divided by the permission object type)
  • "ACO-Frob> Flerg", "ACO-Frob> Queegle" (although the permission object type and node name are the same, the name is valid because the value name is different.
  • "AXO-Frob Hrung> Flerg" (the node name can contain spaces)

Invalid instance naming restrictions:

  • "ACO-Frob> Flerg", "ACO-Frob> Flerg" ("permission object type-node name> value name" must be unique)
  • "ACO-Frob> Flerg Habit" (the value name cannot contain spaces)
Add section

The node name must be added before you can add a new permission object. Add a new node name. you can use the add_object_section () function.

Briefly describe the usefulness of this section (for example, "Levels in building ")

Node name (such as "Floor ")

It can be any value, indicating the order in which the section appears on the user interface

Indicates whether the section appears in the user interface (if it is TRUE, it means it will be hidden ).

Permission object type ("aco", "aro" or "axo ")

Han created three sections for the ARO object: "Humans", "Aliens", and "robots ". Let's use their full names to list the list of ARO objects. Default: reject all
Millennium Falcon passengers
─-Crew member [allow: all]
│ ─ ── "Human> Han"
│ ─ ── "Aliens> Chewie" [reject: engine room]
│ ─ ── "Humans> humans"
Passenger [permitted: lounge]
│ ─-Jedi [allow: cab]
│ ─ ── "Human> Obi-wan"
│ ─ ── "Humans> Luke" [allow: weapons room]
│ ─ ── "Robot> R2D2" [allow: engine room]
│ ─ ── "Robot> C3PO"
└-Engineer [permit: engine room, weapon room]
├ ── "Human> Han"
├ ── "Robot> R2D2"
Yun── "aliens> Hontook"

The section is just a classification method of permission objects, so that the user interface is more friendly and the acl_check () code is more readable. It does not affect the permission of the object determined by phpGACL. It cannot be nested (so it cannot create a "man" subsection under "human", and you will have to create a section similar to "Humans-Male)

Multi-Purpose

You may need to use phpGACL for multiple different purposes. For example, you may need to restrict the user's access to the web page, and also want to restrict the remote host's access to your server. There is no connection between the two tasks.

PhpGACL can be processed in the following three methods.

  • You can save the permission form in another database.
  • Different permission forms can be used for saving in the same database. (This function is not implemented)
  • You can save permission objects for different purposes in the same form and manage your list with caution so that they do not conflict with each other.

You can use the $ gacl_options array to create a new phpGACL class to implement option 1 (The same is true when Option 2 is available). This array allows you to specify the prefix of the database and form name.

$ Gacl_options = array (
'Db _ table_prefix' => 'gacl _',
'Db _ type' => 'mysql ',
'Db _ host' => 'host1 ',
'Db _ user' => 'user ',
'Db _ password' => 'passwd ',
'Db _ name' => 'gacl ');

?

$ Gacl_host1 = new gacl ($ gacl_options );

To implement option 3, you must be very careful, because phpGACL does not know the relationship between your tasks, so it is possible to generate an invalid permission policy.

For example, Han wants to restrict the connection between other ships and their computers. In addition, he wants to restrict the permissions of different rooms. To do this, he may want to add "Luke's X-fighter" as the remote ship's ARO object (in addition, other aircraft can be added and the ship's computer can be used as an ACO object ). Because all the ARO objects are in the same ARO tree, creating an APD is like "X-fighter aircraft of the spacecraft> Luke" [allow: "Room> engine room, it's completely meaningless! To help handle errors like this, a good node name makes the permission objects like this clearer. This is obvious to any administrator: it makes no sense to specify a room access permission for a spacecraft.

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.