phpmv/ubiquity-acl
Composer 安装命令:
composer require phpmv/ubiquity-acl
包简介
Access Control Lists for Ubiquity framework
README 文档
README
Access control lists for Ubiquity framework
Samples
Defining ACLs at runtime
One by one
AclManager::start(); AclManager::addRole('@USER'); AclManager::addResource('Home'); AclManager::addPermission('READ',1); AclManager::allow('@USER','Home','READ');
By grouping
AclManager::start(); AclManager::addAndAllow('@USER','Home','READ');
Defining ACLs with annotations or attributes
Starting
use Ubiquity\security\acl\AclManager; use Ubiquity\security\acl\persistence\AclCacheProvider; AclManager::start(); AclManager::initFromProviders([ new AclCacheProvider() ]);
Defining ACLs in controllers
A controller as a resource, authorized for a role
With annotations:
namespace controllers; /** * @resource('Main') * @allow('role'=>'@USER') */ class TestAclController extends ControllerBase { use AclControllerTrait; }
With attributes:
namespace controllers; use Ubiquity\attributes\items\acl\Resource; use Ubiquity\attributes\items\acl\Allow; #[Resource('Main')] #[Allow(role: '@USER')] class TestAclController extends ControllerBase { use AclControllerTrait; }
Overriding
It is necessary to override the _getRole method so that it returns the role of the active user:
namespace controllers; use Ubiquity\attributes\items\acl\Resource; use Ubiquity\attributes\items\acl\Allow;use Ubiquity\utils\http\USession; use Ubiquity\utils\http\USession; #[Resource('Main')] #[Allow(role: '@USER')] class TestAclController extends ControllerBase { use AclControllerTrait; public function _getRole(){ $activeUser=USession::get('activeUser'); if(isset($activeUser)){ return $activeUser->getRole(); } } }
Defining ACLs with Database
The ACLs defined in the database are additional to the ACLs defined via annotations or attributes.
Initializing
The initialization allows to create the tables associated to the ACLs (Role, Resource, Permission, AclElement).
It needs to be done only once, and in dev mode only.
use Ubiquity\controllers\Startup; use Ubiquity\security\acl\AclManager; $config=Startup::$config; AclManager::initializeDAOProvider($config, 'default');
Starting
In app/config/services.php file :
use Ubiquity\security\acl\AclManager; use Ubiquity\security\acl\persistence\AclCacheProvider; use Ubiquity\security\acl\persistence\AclDAOProvider; use Ubiquity\orm\DAO; DAO::start();//Optional, to use only if dbOffset is not default AclManager::start(); AclManager::initFromProviders([ new AclCacheProvider(), new AclDAOProvider($config) ]);
phpmv/ubiquity-acl 适用场景与选型建议
phpmv/ubiquity-acl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「security」 「mvc」 「tools」 「acl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpmv/ubiquity-acl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpmv/ubiquity-acl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpmv/ubiquity-acl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
Contao CMS integrity check for some files
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
Alfabank REST API integration
统计信息
- 总下载量: 1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2020-10-04