CakePHP 2.1 - 自定义授权对象未加载/执行

发布于 2025-01-08 18:23:20 字数 454 浏览 5 评论 0原文

我正在使用 CakePHP 2.1 RC + TinyAuthorize ,AppController.php 中的下一个方法:

class AppController extends Controller {

    public $components = array('Auth');

    public function beforeFilter() {
        $this->Auth->authorize = array('Tiny');
    }

}

由于某种原因,Tiny 没有被执行,因此它的 ACL 规则没有应用。有什么想法可能是错的吗?

I'm using CakePHP 2.1 RC + TinyAuthorize, the next way in AppController.php:

class AppController extends Controller {

    public $components = array('Auth');

    public function beforeFilter() {
        $this->Auth->authorize = array('Tiny');
    }

}

For some reason, Tiny doesn't get executed, thereby it's ACL rules not applied. Any ideas what could be wrong?

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

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

发布评论

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

评论(1

放低过去 2025-01-15 18:23:20

你把它放在应用程序或工具插件中了吗?
对于后者,应该参见

$this->Auth->authorize = array('Tools.Tiny');

http://www.dereuromark.de/2011/12/18/tinyauth-the-fastest-and-easiest-authorization-for-cake2/详细信息


弄清楚你的问题后,我编辑我的答案:

这个 *(= 任何)“角色”占位符仅指那些已登录的用户。您不能以这种方式声明您的公共行为!所有这些都必须使用 $this->Auth->allow() 声明。

原因是验证先于授权。因此,如果没有身份验证(登录),则永远不会有任何授权(检查角色)。

did you put it in app or tools plugin?
for the latter it is supposed to be

$this->Auth->authorize = array('Tools.Tiny');

see http://www.dereuromark.de/2011/12/18/tinyauth-the-fastest-and-easiest-authorization-for-cake2/ for details


After figuring out your problem I edit my answer:

This * (= any) placeholder for “roles” only refers to those users that are logged in. You must not declare your public actions this way! All those must be declared using $this->Auth->allow().

The reason is that Authenticate comes before Authorize. So without Authentication (logged in) there will never be any Authorization (check on roles).

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