简体   繁体   English

CakePHP ACL:可选的ACO节点(默认情况下允许)

[英]CakePHP ACL: Optional ACO Node (allow by default)

I'm making a CakePHP app using a modified version of database ACL. 我正在使用数据库ACL的修改版本制作CakePHP应用程序。

In order to avoid having to create ACO nodes for every single controller, I would like to establish a system whereby users are allowed access to a page unless otherwise denied . 为了避免必须为每个控制器创建ACO节点,我想建立一个系统, 除非被拒绝,否则允许用户访问页面。 This means that I don't want to create ACO nodes for controllers unless absolutely necessary. 这意味着除非绝对必要,否则我不想为控制器创建ACO节点。

Normally, if I fail to create an ACO node, when my isAuthorised() function performs $this->Acl->check , I get an error such as this... 通常,如果我无法创建ACO节点,则当我的isAuthorised()函数执行$this->Acl->check ,会出现诸如此类的错误...

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node references:
Aro: Array
(
    [model] => Role
    [foreign_key] => 1
)

I think a feasible solution would be to check if the ACO node exists before performing a $this->Acl->check command. 我认为可行的解决方案是在执行$this->Acl->check命令之前检查ACO节点是否存在。 If it doesn't exist, then it would be possible to stop it from checking permissions. 如果不存在,则可以阻止其检查权限。

Is there a way to check out if an ACO node exists, based on the output of $this->Auth->action() (which outputs something like controllers/Members/Edit )? 有没有一种方法可以根据$this->Auth->action()输出(输出类似controllers/Members/Edit )来检查ACO节点是否存在?

My Auth ActionPath is set to 'controllers'. 我的Auth ActionPath设置为“控制器”。

Or maybe there is a better way of going about it? 也许有更好的解决方案?

I hope I have phrased my question adequately, I will ensure to clarify if not. 我希望我已经充分说明了我的问题,如果没有的话,我将确保澄清。

Thanks! 谢谢!

You can use this to check if the Aco exists. 您可以使用来检查Aco是否存在。

if($this->Acl->Aco->node('controllers/Members/Edit')) {
    debug('Aco exists!');
}

If you want to use ACL component you must have ARO and ACO trees. 如果要使用ACL组件,则必须具有ARO和ACO树。 Otherwise there is no sense to use that component. 否则,就没有使用该组件的意义。

I would suggest you to create a super-user for all users, allow him to access all ACO nodes, but deny specific ACO nodes. 我建议您为所有用户创建一个超级用户,允许他访问所有ACO节点,但是拒绝特定的ACO节点。 So, all users would inherit the permissions from that abstract super-user. 因此,所有用户都将从该抽象超级用户那里继承权限。 I guess you have studied Simple Acl controlled Application tutorial , haven't you? 我想您已经学习了Simple Acl控制的应用程序教程 ,不是吗?

Another option would be to use Auth component and write your own permissions handling component. 另一种选择是使用Auth组件并编写您自己的权限处理组件。 There are many tutorials how to build admin panel. 有许多教程如何构建管理面板。

通过对核心ACL.php文件进行编辑来解决此问题,没有正常的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM