ACL,ARO和ACO,如果有新的部分如何更新它们?

发布于 2024-10-29 07:47:40 字数 1690 浏览 1 评论 0原文

如果我在网站中添加了一个部分,我试图了解如何使用 AROACO

CakePHP 指南清楚地说明了 ACL 的概念如何工作,但没有说明如何在代码中实现它。就我个人而言,我发现本教程的所有部分都非常不清楚如何在 CakePHP 框架内使用它们。它似乎是 CakePHP 框架中最不友好的部分。

现在,当我进入我创建的新部分时,我收到此错误,并且我不明白如何修复它。

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node references:
Aro: Array
(
    [User] => Array (
        [id] => 1
        [username] => vittorio
        [group_id] => 1
        [created] => 2011-03-30 10:51:23
        [modified] => 2011-03-30 10:51:23
        [viewable] => 0
    )

)

Aco: controllers/Works/index [CORE/cake/libs/controller/components/acl.php, line 273]

如果我看
http://book.cakephp.org/view/647 /用于创建 ACO 的自动化工具
以及
http://book .cakephp.org/view/996/Creating-Components#!/view/1548/Creating-ACOs-Access-Control-Objects

我应该得到答案,但是如果我运行此代码调用 url mysite.com/build_acl 再次我只收到这些错误:

Missing Controller

Error: BuildAclController could not be found.

Error: Create the class BuildAclController below in file: app/controllers/build_acl_controller.php

<?php
    class BuildAclController extends AppController {

    var $name = 'BuildAcl';
}
?>

Notice: If you want to customize this error message, create app/views/errors/missing_controller.ctp

是否存在一个谈论 ACL、ARO 和 ACO 的体面指南以及如何在 CakePHP 上实现它们而不让读者迷失?

I'm trying to understand how use AROs and ACOs if I've added a section in my site.

The CakePHP guide is clear on how the concept of ACL works, but not on how it should be implemented in the code. Personally I've found all the part of the tutorial very unclear on how they should be used inside CakePHP framework. It seems to be most unfriendly part of CakePHP framework.

Now when I go in new sections I've created, I get this error, and I don't understand how I could fix it.

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node references:
Aro: Array
(
    [User] => Array (
        [id] => 1
        [username] => vittorio
        [group_id] => 1
        [created] => 2011-03-30 10:51:23
        [modified] => 2011-03-30 10:51:23
        [viewable] => 0
    )

)

Aco: controllers/Works/index [CORE/cake/libs/controller/components/acl.php, line 273]

If I look on
http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
and on
http://book.cakephp.org/view/996/Creating-Components#!/view/1548/Creating-ACOs-Access-Control-Objects

I should get the answers, but if I run this code calling the url mysite.com/build_acl again I only get these errors:

Missing Controller

Error: BuildAclController could not be found.

Error: Create the class BuildAclController below in file: app/controllers/build_acl_controller.php

<?php
    class BuildAclController extends AppController {

    var $name = 'BuildAcl';
}
?>

Notice: If you want to customize this error message, create app/views/errors/missing_controller.ctp

Does exist a decent guide who talks about ACL, AROs and ACOs and how to implement them on CakePHP without leave the reader lost?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱给你人给你 2024-11-05 07:47:40

Vittorio

恕我直言, ,ACL 和 AUTH 组合起来是一个非常通用的工具。第一次让它工作让我很恼火。我一遍又一遍地看到的主要错误是:

  • 创建一个或多个新操作后调用build_acl
  • 初始化新出现的设置(新的ACL节点作为输出
    上一步)具有适当的访问权限
    权利。
  • 在从父app_controller继承的每个控制器中调用parent::beforeFilter()(因为关键设置通常驻留在此方法中)。
  • 尝试保存一个 foobared 设置,而不是再次查看本书末尾的 Auth+Acl 教程。它有效(无意冒犯),很多人以前都完成过它,所以你也可以(我并不是说它是瞬间完成的)。
  • 重新发明轮子:在基本功能 Auth+Acl 之后 教程,查看 sourceforgegithub 上的插件。

  • 不是重新发明轮子^^,据我所知,完美的AUTH+ACL管理插件尚未编写(但可用的代码确实存在)

祝您旅途愉快,本杰明。

编辑0
基本的代码卫生会有所帮助,例如,如果您允许用户作为请求对象并允许操作作为受控对象,则将 build_acl() 写入 users_controller 中是有意义的,后面紧跟例如 init_db(),您可以在其中集中设置访问权限。
不要忘记在投入生产之前删除这些黑客行为,即使再次设置正确的访问权限不会造成太大伤害,但想象一下如果约翰·多伊和朋友一直运行此功能,他们会对您的应用程序做什么 Ü

Vittorio,

with due respect, ACL and AUTH combined are a very generic tool. Getting it to work for the first time annoyed me quite a bit. The main errors, which I keep seeing over and over again are:

  • Not calling build_acl after one or more new actions has been created.
  • Not initializing the newly arisen setup (fresh ACL nodes as output of
    the previous step) with proper access
    rights.
  • Not calling parent::beforeFilter() in every controller who inherits from parent app_controller (as often crucial settings reside in this method).
  • Trying to save a foobared setup instead of going over the Auth+Acl tutorial at the end of the book again. It works (no offense), many people accomplished it before, so you can, too (I do not say that it is accomplished instantaneously).
  • Reinventing the wheel: After a basic functioning Auth+Acl tutorial, check out the plugins on sourceforge and github.

  • Not reinventing the wheel ^^, afaik the perfect AUTH+ACL management plugin is yet to be written (but useable code does exist)

Good journey, Benjamin.

Edit0
Basic code hygiene helps, e.g. if you allow users as requesting objects and actions as controlled objects, it makes sense to write the build_acl() into the users_controller, directly followed by, e.g. init_db(), where you centralize settings access rights.
Do not forget to remove these hacks before going into production, even though setting correct access rights again would not hurt much, but imagine what john doe and friends do to your app if they run this function all the time Ü

执手闯天涯 2024-11-05 07:47:40
mysite.com/build_acl

您必须在控制器的任何操作中运行 build_acl ,您不能像引用没有控制器的操作那样调用它。至少你可以尝试这样

mysite.com/{my_controller}/build_acl

或者在app_controller的beforeFilter方法中运行它,例如

function beforeFilter(){
  $this->build_acl();
}

当然函数本身必须在app_controller中声明。

mysite.com/build_acl

you must run build_acl in any action of your controller, you can't call it like that you're referring to an action without controller. at least you can try like this

mysite.com/{my_controller}/build_acl

or run it in app_controller's beforeFilter method e.g.

function beforeFilter(){
  $this->build_acl();
}

of course the function itself must be declared in app_controller.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文