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

最新文章

  1. 【XLL 框架库函数】 TempMissing/TempMissing12
  2. fedora23 tweak tool不工作解决方案
  3. Selenium2+python自动化27-查看selenium API
  4. Ubuntu 安装搜狗拼音及fcitx
  5. Web版报表的架构和设计思路
  6. OC 设计模式——单例模式
  7. 转】Spark DataFrames入门指南:创建和操作DataFrame
  8. 【长篇高能】ReactiveCocoa 和 MVVM 入门
  9. Linux常用命令总结——文件管理
  10. Leetcode-39-Submission Details (Medium)
  11. iOS-swift-协议和拓展
  12. Coredata中的多线程
  13. 3173. 【GDOI2103模拟3.17】扫雷游戏(搜索 + 剪枝)
  14. 使用GSON工具实现json和其他数据格式间转换
  15. Lua5.2&Lua5.3中废除的方法
  16. 20155228 2017-11-19 实现mypwd(选做,加分)
  17. Android NDK学习(三):Hello World
  18. CART决策树(分类回归树)分析及应用建模
  19. Java执行js代码
  20. Jboss7或者wildfly部署war包的问题

热门文章

  1. springBoot AOP切面编程
  2. 牛客网 牛客练习赛13 B.幸运数字Ⅱ-数组 or DFS
  3. K均值聚类(C++)
  4. MapReduce1 工作机制
  5. SQL Server的WAITFOR DELAY注入
  6. JSOI 2009 BZOJ 1444 有趣的游戏
  7. go语言学习之路六:接口详解
  8. xamarin.ios 半圆角按钮Readerer
  9. Linux USB驱动数据结构
  10. oracle exchange partition 測试