locality / cakephp-authorize
此包已被废弃,不再维护。未建议替代包。
CakePHP 插件,包括用于 Acl 组件的新授权类。
dev-master
2014-11-24 07:40 UTC
Requires
This package is not auto-updated.
Last update: 2020-08-31 07:24:29 UTC
README
此插件包含用于与 Acl 组件一起使用的新授权类。
当 ActionsAuthorize 将请求映射到 ACO 节点时,它只允许 /:plugin/:controller/:action 的最大长度。此插件包含的 PathAuthorize 类将允许您使用包含记录 ID 的 ACO 节点。因此,路径现在可以看起来像 /:plugin/:controller/:action/:id。这使得您可以使用 ACL 限制对单个记录的访问。
要求
- PHP 5.2.8
- CakePHP 2.x
安装
[Git]
在您的 CakePHP 插件目录中,运行以下命令
git clone https://github.com/localitysolutions/cakephp-authorize.git Authorize
[Composer]
将以下内容添加到您的 composer.json 文件中的 require
{
"require": {
"locality/cakephp-authorize": "dev-master"
}
}
[手动]
- 从这里下载 zip 文件:https://github.com/localitysolutions/cakephp-authorize/zipball/master
- 解压整个内容。
- 将生成的文件夹重命名为 Authorize。
- 最后,将其复制到 app/Plugin 目录。
使用方法
标准 CakePHP 插件安装,在 app/Config/bootstrap.php 中插入以下行:CakePlugin::load('Authorize');
要使用 PathAuthorize 类进行授权
//in $components public $components = array( 'Auth' => array( 'authorize' => array( 'Authorize.Path' => array('actionPath' => 'controllers') ) ) ); //Or in beforeFilter() $this->Auth->authorize = array( 'Authorize.Path' => array('actionPath' => 'controllers') );