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 规则。有什么想法可能是错的吗?

4

1 回答 1

0

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

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

有关详细信息,请参阅http://www.dereuromark.de/2011/12/18/tinyauth-the-fastest-and-easyest-authorization-for-cake2/


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

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

原因是 Authenticate 在 Authorize 之前。因此,如果没有身份验证(登录),就永远不会有任何授权(检查角色)。

于 2012-02-25T15:26:48.830 回答