marqu3s/yii2-rbac-plus
Composer 安装命令:
composer require marqu3s/yii2-rbac-plus
包简介
Database role base access control manager for yii2
README 文档
README
Database role base access control manager for yii2.
Features
- CRUD operations for roles, permissions and rules
- Allows to assign multiple roles to user
- Nice views to intergrate right away
Installation
The preferred way to install this extension is through composer.
php composer.phar require marqu3s/yii2-rbac-plus
Usage
1. Let's add into modules config in your main config file:
'components' => [ 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], ], 'modules' => [ 'rbac' => [ 'class' => 'marqu3s\rbacplus\Module' ] ]
Next, update the database schema:
php yii migrate/up --migrationPath=@yii/rbac/migrations
Ok. That's done. Avaiable route now:
- /rbac/rule
- /rbac/permission
- /rbac/role
- /rbac/assignment
2. The module configuration avaible
'modules' => [ 'rbac' => [ 'class' => 'marqu3s\rbacplus\Module', 'userModelClassName' => null, 'userModelIdField' => 'id', 'userModelLoginField' => 'username', 'userModelLoginFieldLabel' => null, 'userModelExtraDataColumls' => null, 'beforeCreateController' => null, 'beforeAction' => null ] ],
- userModelClassName: The user model class.
If you not set or set null, RBAC Plus will be get fromYii::$app->getUser()->identityClass - userModelIdField: The user model id field.
Default id field is 'id', you must set this config if primary key of user table in database is not 'id' - userModelLoginField The user model login field.
Default login field is 'username'. Maybe you use email field or something other for login. So you must change this config - userModelLoginFieldLabel The user model login field label.
If you set null the label will get from$userModelClass->attributeLabels()[$userModelLoginField] - userModelExtraDataColumls The extra data columns you want to show in user assign views.
The default in assignment data gridview just display id and login column data. if you want to add created_at column you can add
'userModelExtraDataColumls' => [ [ 'attributes' => 'created_at', 'format' => 'datetime', ] ],
- beforeCreateController The callable before create all controller of Rbac Plus module.
The default it is null. You need config this when you want to restrict access to Rbac Plus module.
Example:
'beforeCreateController' => function($route) { /** *@var string $route The route consisting of module, controller and action IDs. */ }
- beforeActionThe callable before action of all controller in Rbac Plus module.
The default it is null. You need config this when you want to restrict access to any action in some controller of Rbac Plus module.
Example:
'beforeAction' => function($action) { /** *@var yii\base\Action $action the action to be executed. */ }
marqu3s/yii2-rbac-plus 适用场景与选型建议
marqu3s/yii2-rbac-plus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 233 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 marqu3s/yii2-rbac-plus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marqu3s/yii2-rbac-plus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 233
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-12-07