ceeram/authorize

此包已被弃用,不再维护。未建议替代包。

CakePHP 插件,为 AuthComponent 提供授权类。

安装: 16

依赖者: 0

建议者: 0

安全: 0

星标: 23

关注者: 7

分支: 7

类型:cakephp-plugin

1.0.0 2013-09-16 20:17 UTC

This package is not auto-updated.

Last update: 2020-08-21 18:28:59 UTC


README

Build Status Coverage Status

包含一些授权类用于 AuthComponent 的插件。

当前类

  • AclAuthorize,基于行的 Acl。AuthComponent 适配器,与 AclBehavior 创建的 acos 一起使用
  • HabtmDbAcl。AclComponent 适配器,用于用户 habtm 组 Acl。(仅适用于数据库 acl)

要求

  • PHP 5.2.8
  • CakePHP 2.x

安装

[手动]

[GIT 子模块]

在您的应用目录中输入

git submodule add git://github.com/FriedsOfCake/Authorize.git Plugin/Authorize
git submodule init
git submodule update

[GIT 克隆]

在您的插件目录中输入

git clone git://github.com/FriendsOfCake/Authorize.git Authorize

使用

app/Config/bootstrap.php 中添加: CakePlugin::load('Authorize');

AclAuthorize 配置

设置授权类

示例

    //in $components
    public $components = array(
        'Auth' => array(
            'authorize' => array(
                'Controller',
                'Authorize.Acl' => array('actionPath' => 'Models/')
            )
        )
    );
    //Or in beforeFilter()
    $this->Auth->authorize = array(
        'Controller',
        'Authorize.Acl' => array('actionPath' => 'Models/')
    );

在上面的示例中,首先检查 ControllerAuthorize。如果您的 Controller::isAuthorized() 在 admin 路由上返回 true,则 AclAuthorize 只会检查非 admin url。您还需要以类似的方式设置 actionPath,它用于 Actions- 和 CrudAuthorize。

HabtmDbAcl 配置

设置 HabtmDbAcl 适配器

在 app/Config/core.php 中

Configure::write('Acl.classname', 'Authorize.HabtmDbAcl');

确保您需要修改 HabtmDbAcl 的设置时,将这些设置传递给 AclComponent $settings['habtm'],并在任何 Auth 配置之前加载它。

    //in $components
    public $components = array(
        'Acl' => array('habtm' => array(
            'userModel' => 'Users.User',
            'groupAlias' => 'Group'
        )),
        'Auth' => array(
            //your Auth settings
        )
    );