isAllowed 用于单个角色(不是角色继承的角色)
我试图使用 Zend Acl 找出角色是否可以显式访问资源,但是 Zend Acl 的 isAllowed 方法不仅检查角色,还检查指定角色继承的任何角色,我不关心这些,我只想知道角色本身是否被允许。
对于某些上下文,我正在为管理员构建一个界面,以便在每个用户的基础上更改 acl 规则,因此我希望他们能够查看某个角色是否被明确允许、继承了访问权限,或者被明确拒绝访问资源。
I'm trying to find out if a role has explicit access to a resource using Zend Acl, but Zend Acl's isAllowed method not only checks the role, but also any roles the specified role inherits, which I don't care about, I only want to know if the role on it's own is allowed.
For some context, I'm building an interface for administrators to change acl rules on a per user basis, so I want them to be able to see if a role is explicitly allowed, has inherited access, or is explicitly denied access to a resource.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常您会从某个地方(比如数据库)读取 ACL 的设置。那就是你应该看的地方。无论如何你都需要把它写在那里。
Usually you read the settings for the ACL from somewhere, lets say a DB. Thats the place, where you should look at. You need to write it there anyway.
我认为您以错误的方式看待 Zend_Acl 。
整个系统是基于父/子的
如果您不需要父/子关系,则必须为每个角色定义每个规则:
访客可以登录
访客无法注销
用户可以登录
用户可以注销
或者您可以扩展 Zend_Acl 并创建您自己的 isExplicitAllowed() 方法。
I think you are looking at Zend_Acl the wrong way.
The whole system is based on parent/child
If you don't need a parent/child relationship you will have to define each rules for each roles:
Guest can loggin
Guest cannot logout
User can loggin
user can logout
Or you can extend Zend_Acl and create your own isExplicitAllowed() method.