热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

[翻译]PhpGACL手册(二)

不知不觉已经开始写了,看来只要下定决心,速度还是不赖的嘛。这样看来本人的行动力还行,就是翻译的水平差了点,大家也就将就将就吧

不知不觉已经开始写了,看来只要下定决心,速度还是不赖的嘛。这样看来本人的行动力还行,就是翻译的水平差了点,大家也就将就将就吧,反正大致意思是 不会错的!呵呵!!E文好的牛人们呢,有心的你就直接看原文,有心的你就帮忙改改(有点象走江湖的口吻,有钱的捧个钱场,无钱的捧个人场,^-^)如果您 老实在看不下来,那就自己再译一个,我这也算是间接为文档中文化做出了点贡献,呵呵!

Defining access control with phpGACL
phpGACL设置权限控制

It seems that for large or complex situations, this 'access matrix' approach is clearly unsuitable. We need a better system that maintains the advantages (fine-grain control and a clear idea of who has access to what) but removes the disadvantages (difficult to summarize, and difficult to manage large groups of people at once). One solution is phpGACL.
看来对于大型或复杂的情况来说,采用"权限表"方法明显不适用。我们需要一个更好的系统来继承权限表的优点(精细权限控制及能访问什么的清晰思路)同时摒弃它的不足(总结和大规模权限管理的困难)。phpGACL就是这样的系统之一。

phpGACL doesn't describe access from the 'bottom-up' like the Access Matrix above. Instead, it describes it 'top-down', like the textual description of Han's access policy. This is a very flexible system that allows you to manage access in large groups, it neatly summarizes the access policy, and it's easy to see who has access to what.
phpGACL
并不象上面"权限表"那样采用"自底向上"的方式来描述权限,相反,它采取"由顶向下"来描述权限,象Han所说那段话所表现的权限策略那样。这是一个十分灵活的系统允许你去管理大量的权限,它能简明扼要地总结权限策略而且更容易看清是有权访问什么

An ARO tree defines a hierarchy of Groups and AROs (things that request access). This is very similar to a tree view of folders and files. The 'folders' are the Groups and the 'files' are AROs.
ARO
树定义ARO对象(要求访问权限的事物)和组的等级关系,它同文件目录树非常相似,其中的组就相当于文件夹而ARO对象则相当于文件。

Let's make an ACL tree for the people on Han's ship. First we define some categories for the people. It's clear that Han and Chewie run the ship, and the rest of them are just passengers:
让我们为Han的船上的人建立一个ACL树。首先我们先把人分成几类,可以很清楚地知道HanChewi是开船的,其他人则是乘客:

phpGACL

Millennium Falcon Passengers(千年隼号乘客)  Group(组)
├─Crew(
船 员) Group(组)
│ ├─Han ARO
│ └─Chewie ARO
└─Passengers (乘客) Group(组)
├─Obi-wan ARO
├─Luke ARO
├─R2D2 ARO
└─C3PO ARO

 

This tree by itself doesn't specify any access policy; it just shows how we're grouping the people who might request access (AROs).
该树自身并不指定任何权限策略;它只是显示我们如何对需要权限的人(即ARO对象)进行分组

We apply access restrictions by assigning instructions about a particular room (ACO) to Groups or AROs in the tree. Han says: "By default, no-one should be allowed access to any room on the Millennium Falcon. But the Crew should have access to every room. The Passengers should only have access to the Lounge."
我们将对指定房间(ACO对象)的权限限制应用到树中的组或ARO对象上。Han说:"在缺省情况下,千年隼号上没有人有权力进入房间。除了船员可以进入任何房间,而乘客只能进休息室。

phpGACL

Millennium Falcon Passengers(千年隼号乘客)
├─Crew (船员) [ALLOW: ALL(允许:全部)]
│ ├─Han
│ └─Chewie
└─Passengers (乘客) [ALLOW: Lounge(允许:休息室)]
├─Obi-wan
├─Luke
├─R2D2
└─C3PO

To interpret this ARO tree, we start from the top and work our way down.
我们按我们的方式"自顶向下"地来解释这个ARO树。

Firstly, the default policy is always to deny access. Permissions have been overridden for the "Crew", so they have access to everywhere ("ALL" is a synonym for all rooms: "Cockpit, Lounge, Guns, Engines"). The "Passengers" have access only to the Lounge.
首先,缺省的策略总是拒绝任何访问权限的。许可对于船员来说是无效的,因此他们拥有去任何房间的权限("ALL"权限对所有房间都一样,如驾驶室,休息室,武器室和发动机室)。而乘客则只有到休息室的权限。

This way of describing the access policy is much clearer than the access matrix. You can easily see who has access to what, and it's easier to determine why they've got access (it seems obvious that Han and Chewie would have access to everything, since they're grouped under "Crew").
这种描述权限策略的方式比用权限表更加简明。人们可以很容易地看出谁对什么拥有权限,并且也可以很清楚地说明为什么他们拥有权限(这看上去很显然,HanChewie拥有去任何房间的权限,因为他们被分在"船员"组)

To summarize
总结
:
  • Access Control Objects (ACOs) are the things we want to control access to (e.g. web pages, databases, rooms, etc).
    权限控制对象(ACO对象)是我们想要控制的事物(如网页,数据库,房间等)
  • Access Request Objects (AROs) are the things that request access (e.g. people, remote computers, etc)
    权限需求对象(ARO对象)是要求权限的事物(如人们,远程计算机等)
  • ARO trees define a hierarchy of Groups and AROs. Groups can contain other Groups and AROs.
    ARO
    树则定义了ARO对象及组的级别,组可以包含其他组和ARO对象。
  • The default 'catch-all' policy for the ARO tree is always "DENY ALL".
    ARO树缺省的"catch-all"(全部阻止了)策略总是拒绝所有权限的。
  • To assign access policy, work your way down the tree, explicitly assigning permissions to Groups and AROs for each ACO as the need arises.
    为分配权限策略,在ARO树上按照你的想法自顶向下明确地为每一个ACO对象分配所需的权限给组和ARO对象

Fine-grain access control 
高精度权限控制

Oops! What about Chewie? By grouping him in "Crew", Han has indirectly given him access to the Engines! He doesn't want that after what Chewie recently did to the hyperdrive, so he adds a rule to disallow this:
哎呀!Chewie怎么办呢?他被分入了"船员"组,Han已经间接地给了他到发动机室的权限了!但这并不是他所想的,因此他增加了一条规则来禁止这个权限:

千年隼号乘客
船员 [允许:全部]
│├─Han
│└─Chewie [
拒绝:发动机室]
乘客 [允许:休息室 ]
├─Obi-wan
├─Luke
├─R2D2
└─C3PO

This is an example of the way you can control access policy in a fine-grained manner. It is not necessary to move Chewie to another Group; we simply over-ride the access policy at a lower level.
这是一个例子,表明你如何用高精度的方式来进行权限策略的控制。通过这种方式你不需要将Chewie移入另一个组中;我们只需要简单地在较低的层次中覆写权限策略就可以了。
Another example of fine-grain control happens when the Empire attacks; Han needs to let Luke man the guns, and let R2D2 repair the hyperdrive in the Engine room. He can do this by over-riding the general permissions granted by their status as a "Passenger":
另一个高精度控制的例子发生在受到帝国袭击时,Han需要Luke操纵武器,R2D2修理发动机室中的引擎。他可以通过覆写他们作为乘客的通用权限就来实现这一改变:
千年隼号乘客
船员 [允许:全部]
│├─Han
│└─Chewie [
拒绝:发动机室]
乘客 [允许:休息室 ]
├─Obi-wan
├─Luke
[
允许:武器室]
├─R2D2
[
允许:发动机室]
└─C3PO
 phpGACL

Multi-level Groups
多层次组

Groups can be extended to any level in the ARO tree. For example, you could add a Group "Jedi" to "Passengers". Most passengers would be categorized under "Passengers", but Luke and Obi-wan would be under "Jedi" and therefore might be extended extra privileges (like access to the Cockpit):
组可以扩展到ARO树中的任何一个层次。例如,你可以增加"绝地战士"组到"乘客"组中,大多数乘客将被分到"乘客"组下,但LukeObi-wan将被分到"绝地战士"组下,因此他们也就扩展了其他额外的权利(如可以到驾驶室)

千年隼号乘客
船员 [允许:全部]
│├─Han
│└─Chewie [
拒绝:发动机室]
乘客 [允许:休息室 ]
├─
绝地战士 [允许:驾驶室]
├─
Obi-wan
└─
Luke [
允许:武器室
├─R2D2 [
允许:发动机室]
└─C3PO

How does phpGACL determine permissions?
phpGACL
怎样确定权限呢?

When the ship's computer (running phpGACL of course) checks access, the only question it can ask itself is "Does person X have access to room Y?" In phpGACL terms, this is rephrased as "Does ARO 'X' have access to ACO 'Y'?"
当飞船上的计算机(当然运行是的phpGACL了)检查权限时,它只需要问自己这样一个问题:"X人有权进入Y房间吗?"用phpGACL的说法就是"ARO对象X有权访问ACO对象Y吗?"

phpGACL determines whether a specific person has access to a specific room by working from the top of the ARO tree towards the specified person, noting explicit access controls for that place along the way. When it reaches that person, it uses the last explicit access control it encountered as the result to return. In this way, you can define access controls for groups of people, but over-ride them further down the tree if you need to.
phpGACL
通过从ARO树的顶部向下遍历的方式,直到找到那个人,明确其访问控制权限来确定该人是否有权访问指定房间。当它找到那个人时,它将它最终遇到的访问控制权限作为结果返回。通过这种方式,你能够为人们所属的组定义访问控制权限,但也可以在你需要时在树的下一层次覆写它们。

Example 1: We ask: "Does Luke have access to the Lounge?".
1:我们问"Luke有访问休息室的权限吗?"
  • Set the default result, "DENY".
    设置缺省结果,"拒绝"

  • Work out a path to Luke:
    遍历ARO树以找到Luke

Millennium Falcon Passengers → Passengers → Jedi → Luke
千年隼号乘客→ 乘客→ 绝地战士→ Luke

  • Start at the top of the tree and move towards Luke: The "Millennium Falcon Passengers" node doesn't say anything about any room, so do nothing here.
    ARO树顶开始遍历到Luke:"千年隼号乘客"节点没有定义任何权限,所以这儿不做任何事情。

  • Move on to "Passengers", which explicitly says that "Passengers" have Lounge access, so change the internal result to "ALLOW".
    移动到"乘客"节点,这儿清楚地表示"乘客"有进入休息室的权限,所以改变内部结果为"允许"。

  • Move to the "Jedi" node, which doesn't mention the Lounge at all.
    移动到"绝地战士"节点,这儿根本没有提到任何关于休息室的话。

  • Finally move to Luke's node, and again there's nothing there about the Lounge.
    最后移动到Luke,这儿也没提至休息室

  • There's nowhere left to go, so the result returned is the current value of the internal result: "ALLOW"
    现在已经到达终点了,所以返回结果就是当前的内部结果值:"允许"

Example 2: We ask: "Does Chewie have access to the Engines?"
2:我们问:"Chewie有权访问发动机室吗?"
  • Set the default result, "DENY".
    设置缺省结果,"拒绝"

  • Work out a path to Chewie:
    遍历ARO树以找出Chewie:

Millennium Falcon Passengers → Crew → Chewie
千年隼号乘客→ 船员→ Chewie

  • Start at the top of the tree and move towards Chewie. The "Millennium Falcon Passengers" node doesn't say anything about anywhere, so do nothing here.
    ARO树顶开始遍历到Chewie,"千年隼号乘客"节点没有定义任何权限,所以这儿不做任何事情。

  • Move on to "Crew", which explicitly says that "Crew" have Engine access, so change the internal result to "ALLOW".
    移至"船员"节点,该节点明确表明"船员"组拥有访问发动机室的权限,因此改变内部结果为"允许"。

  • Move to Chewie's node, and there's an explicit rule saying that he doesn't have access to the Engines, so change the internal result to "DENY".
    移至Chewie节点,该节点规则表明没有访问发动机室的权限,因此改变内部结果为"拒绝"。

  • There's nowhere left to go, so the result returned is the current value of the internal result: "DENY"
    现在已经到达终点了,所以返回结果就是当前的内部结果值:"拒绝"

As you can see from the examples, if a Group doesn't explicitly specify a permission for a room, then that Group inherits the access restrictions of its parent for that room. If the root node ("Millennium Falcon Passengers") doesn't specify a permission, it inherits it from the default setting ("DENY ALL" in the above examples).
就象你从例子上看到的那样,如果一个组没被明确指定访问某个房间的权限的话,那么该组就会继承其父节点对该房间的权限。如果根节点("千年隼号乘客")也没有被指定权限的知,则它继承它的缺省设置(在上面的例子里是"全部拒绝")

This implies a couple of interesting points about the ARO tree:
从上面的例子我们不难看出ARO树中有意思的几点:

  • The ARO tree always shows the full list of the AROs. It would not make sense to ask "Does Jabba have access to the Cockpit?" because Jabba has not been defined in this system. However, phpGACL does not check to see if AROs or ACOs exist before performing the check, so if this question was actually asked then the result would be the default "DENY".
    ARO
    树总是列出完整的ARO对象列表。如果问题是"Jabba是否有权进入驾驶室?"那就显得很不合理了,因为Jabba并未在这个系统中提及。然而,phpGACL在进行权限检查之前并不检查ARO对象或ACO对象是否存在,因此如果真被问及上述问题,则返回的结果将是缺省值"拒绝"。

  • The ARO tree may not display some defined ACOs, and relies on the default setting to define access policy. For example, say Han defined a "Bathroom" ACO. Any question like "Does Luke have access to the Bathroom?" would have the answer "DENY", because the default is "DENY" and nowhere in the ARO tree does it ever explicitly mention the Bathroom. Keep in mind when examining the ARO tree that some ACOs may not be visible.
    ARO树中也许并不显示某些已被定义的ACO对象,而是凭借缺省值来进行权限策略的设定。比如说Han定义了一个"浴室"ACO对象,那么任何诸如"Luke有权进浴室吗?"这样的问题将会得到"拒绝"这样的回答,因为在ARO树中没有任何地方明确地说明了浴室的权限而缺省的值又是"拒绝"。请记住检查ARO树时有些ACO对象也许是看不见的。

Note: When asking phpGACL questions about access to an ACO, it is not possible to use Groups as AROs (even though it might 'seem' right). For example, it is impossible to answer the question "Do Passengers have access to Guns?" The complete answer is not a Boolean "ALLOW" or "DENY", but the more complex "Luke and Obi-wan can but R2D2 and C3PO cannot." phpGACL is not designed to return that kind of answer.
注意:当询问phpGACL系统对某个ACO对象的权限时,它不可能使用组来代替ARO对象的(尽管那看上去可能是合理的)。比如说象回答诸如"乘客是否有权进入武器室?"之类的问题,完整的回答不是一个简单的"允许"或"拒绝",而是更为复杂的"LukeObi-wan可以,而R2D2C3PO不可以。"phpGACL系统没有被设计成能返回这样的回答。 


推荐阅读
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • LeetCode笔记:剑指Offer 41. 数据流中的中位数(Java、堆、优先队列、知识点)
    本文介绍了LeetCode剑指Offer 41题的解题思路和代码实现,主要涉及了Java中的优先队列和堆排序的知识点。优先队列是Queue接口的实现,可以对其中的元素进行排序,采用小顶堆的方式进行排序。本文还介绍了Java中queue的offer、poll、add、remove、element、peek等方法的区别和用法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 也就是|小窗_卷积的特征提取与参数计算
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了卷积的特征提取与参数计算相关的知识,希望对你有一定的参考价值。Dense和Conv2D根本区别在于,Den ... [详细]
  • FeatureRequestIsyourfeaturerequestrelatedtoaproblem?Please ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
author-avatar
狮子小刚刚
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有