Yii accessControl不起作用.accessRules()


Yii accessControl does not work. accessRules()

我已经多次使用accessRules(),但突然在一个新项目中,它开始对我不起作用。

我就是这样分配的。

class DefaultController extends AppController
{
    public function filters()
    {
        return array(
            'accessControl',
        );
    }
    public function accessRules()
    {
        return array(
            array('allow',
                'actions'=>array('index'),
                'users'=>array('*'),
            ),
            array('deny',
                'users'=>array('*'),
            ),
        );
    }
    /**
     * Declares class-based actions.
     */
    public function actions()
    {
        return array(
            'list'=>'api.controllers.default.ListAction',
            'index'=>'api.controllers.default.IndexAction',
            'deviceSignUp'=>'api.controllers.default.DeviceSignUpAction'
        );
    }
}

我有一个动作叫list。作为打击,

class ListAction extends RestAction
{
    public function run()
    {}
}

问题是,尽管我已经对除索引之外的所有其他操作进行了否认。我仍然可以通过www.mywebsite.com/default/list查看ListAction,这实际上会给我一个未通过身份验证的错误。这里缺少什么,或者为什么accessControl不起作用?

@symbol表示授权用户,*指所有用户。

使用典型的accessControl数组:

return array(
        array('allow',  // allow all users to some public actions
            'actions'=>array(<PUBLIC ACTIONS LIST>),
            'users' => array('*'),
        ),
        array('allow',  // allow all authorized users to some actions
            'actions'=>array(<AUTHORIZATION-NEEDED ACTIONS LIST>),
            'users' => array('@'),
        ),
        array('deny', // deny all other actions
            'users' => array('*'),
        ),              
);