CakePHP 2.0:ACL不起作用 [英] CakePHP 2.0: ACL not working

查看:56
本文介绍了CakePHP 2.0:ACL不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CakePHP 1.3中使用ACL时没有出现任何问题,经过2周的痛苦挫折后,它在CakePHP 2.0中仍然无法使用。

I have used ACL in CakePHP 1.3 without a single issue, after 2 weeks of bitter frustrations it still does not work in CakePHP 2.0.

我一直在关注Cake ACL教程完全正确,但是没有任何反应。所有Aros的位置正确,ACOS和权限相同。

I have followed the Cake ACL tutorial EXACTLY, but nothing happens. All Aros are in correctly, same for ACOS and permissions.

毕竟,我可以毫无问题地输入所有被拒绝的动作。

After all this, I can enter all denied actions without a problem.

这里是我的AppController:

Hereby my AppController:

public $components = array('Acl','Auth'=> array(
                            'authenticate' => array(
                                'Actions',
                                'Form' => array(
                                    'fields' => array('username' => 'email')
                                    ),
                            )
), 'Session', 'MathCaptcha', 'RequestHandler');

在我的BeforeFilter中:

In my BeforeFilter:

    $this->Auth->actionPath = 'controllers';
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'home');
    $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'profile');
    $this->Auth->allow('display');

有人知道哪里出了问题。谢谢!

Does someone have an idea what goes wrong. Thanks!

推荐答案

在CakePHP 2.0中,我是这样做的:

In CakePHP 2.0 I've made this way:

app / Controller / AppController.php

app/Controller/AppController.php

class AppController extends Controller {

    public $components = array(
        // others components...
        'Session',
        'Acl',
        'Auth'=> array(
            // Setting AUTHORIZATION "What can you do?"
            'authorize' => array(
                'Actions' => array(
                    'actionPath' => 'controllers'
                 )
            ),

            // Setting AUTHENTICATION "Who are you?"
            'authenticate' => array(
                'Form' => array(
                    'fields' => array(
                        'username' => 'email', 'password' => 'password'
                    )
                )
            )
        )
    );

// other stuffs...

通过此方法,ACL将使所有肮脏的工作。

With this aproach, ACL will make all dirty job. Is not necessary to check permitions, as you probably know.

我相信您对ARO和ACO没什么大不了的。以防万一:
http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-受控应用程序/ simple-acl-受控应用程序.html#simple-acl-受控应用程序

I believe you are Ok about AROs and ACOs, not big deal. Just in case: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html#simple-acl-controlled-application

CakeBook for 2.0显示了一个名为AclExtras的控制台插件,用于构建您的ACO。将在添加/删除用户和组时构建您的ARO。我已经使用此插件生成有关我已经填写的表格的ARO: http:// www。 alaxos.ch/blaxos/pages/view/plugin_acl 。可以在fos 1.3上运行,但是有2.0版的beta版本可以正常工作。

The CakeBook for 2.0 shows a Console plugin called AclExtras that build your ACOs. Your AROs will be built as users and groups are added/deleted. I've used this plugin to generate AROs regarding my already filled tables: http://www.alaxos.ch/blaxos/pages/view/plugin_acl. This works fos 1.3, but there is a beta version for 2.0 that works ok.

在那之后,您必须设置许可。通过此链接手动(或从控制台)描述: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-control-application/part-two.html#setting-up-权限。或在视觉上使用Alaxos的插件。

After that, You must set up permitions. Manually (or from Console) as this links describes: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/part-two.html#setting-up-permissions. Or visually with Alaxos's Plugin.

我希望这项帮助!对我有用。我正在使用CakePHP 2.0.2

I hope this help! It's worked for me. I'm using CakePHP 2.0.2

这篇关于CakePHP 2.0:ACL不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆