Zend_Acl 白名单 VS 黑名单?
我应该对 Zend_Acl 使用白名单还是黑名单方法?我的意思是拒绝向每个人提供任何和所有资源,并为每个角色编写每个允许案例[黑名单],或者允许所有资源并为每个角色编写每个拒绝护理[白名单]
Should i use a whitelist or blacklist approach to Zend_Acl? By that i mean deny any and all resources to everyone and write each single allow case for each role [blacklist] or allow all resources and write each deny care for each role [whitelist]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不需要指定每个被拒绝的角色。
首先,您应该将所有角色定义为被拒绝。之后,为每个角色设置允许的访问资源。因此,您未声明为允许资源的每个角色都将被自动拒绝。
像这样的东西:
don't need to specify every denied role.
at first you should define all of role as denied. after that, set allowable access resource for every role. so every role that you haven't declare as allowed for resource will be automatically denied.
something like this :
我正在使用白名单方法。这意味着我有一个 DenyAll 作为启动策略,并且仅在检查给定角色的权限后才授予对资源的访问权限。我认为这是一种更安全的做法。在相同的情况下,您可以根据您的大部分资源情况来选择其中之一。例如,如果您的网站的大部分内容都是公开的,则从 allowedAll 开始,然后拒绝对 x 资源的访问。这会限制 ACL 树的生长。
I am using a white-list approach. This means I have a denyAll as a start policy and a grant access to resources only after checking the permissions for the given role. I think is a safer practice. In same cases you could choose one over another depending on how most of your resources are. For example if most of your website is public start from allowAll and just deny access to x resources. This can limit the growth of your ACL tree.
除非有什么事情困扰你去做相反的事情,否则你应该总是做那些需要较少努力来实现的事情。
Unless anything is bothering you to do the opposite, you should always do whatever requires less effort to implement.
由于您甚至没有提到您想要实现的目标是什么,因此任何人都无法给出一个好的答案。最合适的解决方案将取决于您的具体用例,因此要么提供更多信息,要么自己决定什么是最佳解决方案。
Since you don't even mention what it is exactly that you want to achieve, there's no way anybody can give a good answer. The most fitting solution will depend on your specific use case, so either provide more information or decide for yourself what's the best solution.