CakePHP 2.1 - 自定义授权对象未加载/执行
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你把它放在应用程序或工具插件中了吗?
对于后者,应该参见
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
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).