【问题标题】:Cakephp 2 acl not denying any actionsCakephp 2 acl 不否认任何动作
【发布时间】:2013-02-16 10:03:05
【问题描述】:

我按照教程进行操作,没有收到任何错误,但 acl 允许所有用户执行所有操作。我使用 aclmanager 检查了所有权限是否正确显示。我添加了 parent::beforeFilter();在所有控制器中。我错过了什么吗?有人可以帮我解决这个问题吗?

这是我的 initDB 函数

public function initDB() {
$group = $this->User->Group;

$group->id = 1;
$this->Acl->allow($group, 'controllers');

$group->id = 2;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Employees');

 $group->id = 3;
$this->Acl->deny($group, 'controllers');
//we add an exit to avoid an ugly "missing views" error message
echo "all done";
 }

这是我在 appcontroller 中的 beforefilter 函数

function beforeFilter(){
$this->Auth->authorize = array(
    'Controller',
    'Actions' => array('actionPath' => 'controllers')
    );
$this->Auth->authenticate = array('Form' => array('fields' => array('username' =>          'username', 'password' => 'password')));   
 $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'employees', 'action' =>   'employee_list');
 }

【问题讨论】:

    标签: cakephp acl


    【解决方案1】:

    您确定已启用 acl 组件吗?

    检查您的AppController 一段时间,例如:

    public $components = array(
            'Acl',
            'Auth' => array(
                'authorize' => array(
                    'Actions' => array('actionPath' => 'controllers')
                )
            ),
            'Session'
    );
    

    【讨论】:

    • 还要确保您的 acl 数据库表(例如 acos)已填充。
    • 是的,我检查了 Acl 组件已启用,并且已填充 acos、aros、aros_acos 表。
    猜你喜欢
    • 1970-01-01
    • 2013-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    相关资源
    最近更新 更多