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


CakePHP 2.1 - custom authorization object not loaded/executed

我正在使用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规则没有被应用。有什么想法吗?

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

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

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


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

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

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