Yii的权限管理rbac
2024-08-23 10:17:00
1.首先我们要在配置文件的组件(component)里面配置一下 Rbac
在对应项目下的config/main.php或者config/main-local.php下添加
'authManager' => [
'class' => 'yii\rbac\DbManager',
'itemTable' => 'auth_item',
'assignmentTable' => 'auth_assignment',
'itemChildTable' => 'auth_item_child',
],
2.生成rbac默认数据表
a.运行下面的命令生成权限数据表:
yii migrate --migrationPath=@yii/rbac/migrations/
b.也可以打开vendor\yiisoft\yii2\rbac\migrations\schema-mysql.sql 拷贝里面的内容到数据库运行生成数据表
3.权限分配有4张表
auth_rule:单独存放Rule,跟auth_item中的rule_name字段对应 auth_item:存放Role和Permission,以type字段区别,1为Role,2为Permission auth_item_child:Role拥有的Permission,一个Role可以有多个Permission auth_assignment:用户拥有的Role,一个用户可以有多个Role
官方: http://www.yiichina.com/doc/guide/2.0/security-authorization
http://www.yiichina.com/tutorial/433
http://www.manks.top/yii2_frame_rbac_template.html
http://www.yii-china.com/post/detail/32.html
http://www.yiichina.com/tutorial/869
最新文章
- 【XLL 框架库函数】 TempMissing/TempMissing12
- fedora23 tweak tool不工作解决方案
- Selenium2+python自动化27-查看selenium API
- Ubuntu 安装搜狗拼音及fcitx
- Web版报表的架构和设计思路
- OC 设计模式——单例模式
- 转】Spark DataFrames入门指南:创建和操作DataFrame
- 【长篇高能】ReactiveCocoa 和 MVVM 入门
- Linux常用命令总结——文件管理
- Leetcode-39-Submission Details (Medium)
- iOS-swift-协议和拓展
- Coredata中的多线程
- 3173. 【GDOI2103模拟3.17】扫雷游戏(搜索 + 剪枝)
- 使用GSON工具实现json和其他数据格式间转换
- Lua5.2&;Lua5.3中废除的方法
- 20155228 2017-11-19 实现mypwd(选做,加分)
- Android NDK学习(三):Hello World
- CART决策树(分类回归树)分析及应用建模
- Java执行js代码
- Jboss7或者wildfly部署war包的问题