Cakephp 对使用Auth的非用户组检查权限->;授权=";行动“;

Cakephp 对使用Auth的非用户组检查权限->;授权=";行动“;,cakephp,authorization,cakephp-1.3,authorize,Cakephp,Authorization,Cakephp 1.3,Authorize,谁能给我解释一下Auth->authorize=“actions” 在我的项目中,我计划给出这一点。 正如教我的那样,授权将调用$this->Aro->check($user,“controllers/:controllers/:action”) 这将对照用户权限检查用户权限?? 这意味着用户应该在aros表中。 但我不需要这个来检查用户,但我需要检查组 我怎样才能做到这一点 现在,当用户不在Aro表中时,它将显示 因此,Aro将只是组,需要向Aro添加用户 提前谢谢看看这个。要检查组权限,请执

谁能给我解释一下
Auth->authorize=“actions”

在我的项目中,我计划给出这一点。
正如教我的那样,授权将调用
$this->Aro->check($user,“controllers/:controllers/:action”)

这将对照用户权限检查用户权限??
这意味着用户应该在aros表中。
但我不需要这个来检查用户,但我需要检查组
我怎样才能做到这一点

现在,当用户不在Aro表中时,它将显示

因此,Aro将只是组,需要向Aro添加用户

提前谢谢

看看这个。要检查组权限,请执行此操作(“模型”和“外键”值来自aros表):

看看这个。要检查组权限,请执行此操作(“模型”和“外键”值来自aros表):

得到了解决方案
使用此
我将AuthComponent扩展到CustomAuth,并覆盖AuthComponent中的
isAutomatized()
方法,如下所示

在controllers/components/custom_auth.php中

    <?php
App::import('Component','Auth');
class CustomAuthComponent extends AuthComponent {

    public function isAuthorized($type = null, $object = null, $user = null) {

        $actions  = $this->__authType($type);
        if( $actions['type'] != 'actions' ){
            return parent::isAuthorized($type, $object, $user);
        }
        if (empty($user) && !$this->user()) {
            return false;
        } elseif (empty($user)) {
            $user = $this->user();
        }


        $group = array('model' => 'Group','foreign_key' =>$user['Login']['group_id']);
        $valid = $this->Acl->check($group, $this->action());
        return $valid;
    }
}
?>
这解决了我的问题:)

得到了解决方案
使用此
我将AuthComponent扩展到CustomAuth,并覆盖AuthComponent中的
isAutomatized()
方法,如下所示

在controllers/components/custom_auth.php中

    <?php
App::import('Component','Auth');
class CustomAuthComponent extends AuthComponent {

    public function isAuthorized($type = null, $object = null, $user = null) {

        $actions  = $this->__authType($type);
        if( $actions['type'] != 'actions' ){
            return parent::isAuthorized($type, $object, $user);
        }
        if (empty($user) && !$this->user()) {
            return false;
        } elseif (empty($user)) {
            $user = $this->user();
        }


        $group = array('model' => 'Group','foreign_key' =>$user['Login']['group_id']);
        $valid = $this->Acl->check($group, $this->action());
        return $valid;
    }
}
?>

这就解决了我的问题:)

但是既然给出了Auth->authorize=“actions”,检查将自动完成,对吗?没错。您需要使用
$this->Auth->authorize='controller'
isAuthorized()
method()。但是如果我给
$this->Auth->authorize='controller'我需要转到每个控制器并覆盖
isAuthorized()
。如何在每个控制器中避免这种重写?然后,我还需要从每个已尝试并失败的控制器调用
isAuthorized()
,但由于已给出Auth->authorize=“actions”,检查将自动完成,对吗?没错。您需要使用
$this->Auth->authorize='controller'
isAuthorized()
method()。但是如果我给
$this->Auth->authorize='controller'我需要转到每个控制器并覆盖
isAuthorized()
。如何在每个控制器中避免这种重写?然后我还需要从每个已尝试但失败的控制器调用
isAuthorized()
function beforeFilter()
{
$this->CustomAuth->userModel = 'Login';
$this->CustomAuth->allowedActions = array('display');
$this->CustomAuth->actionPath = 'controllers/';
$this->CustomAuth->authorize = 'actions';
}