@@ -17,10 +17,11 @@ composer require windhoney/yii2-rest-rbac
17
17
],
18
18
'oauth2' => [
19
19
'class' => 'filsh\yii2\oauth2server\Module',
20
+ //'class' => 'wind\oauth2\Module',相对filsh\yii2\oauth2server做了一点优化,增加了可修改oauth2表的db name
20
21
'tokenParamName' => 'access_token',
21
22
'tokenAccessLifetime' => 3600 * 24,
22
23
'storageMap' => [
23
- 'user_credentials' => 'backend \models\User',
24
+ 'user_credentials' => 'common \models\User',//可自定义
24
25
],
25
26
'grantTypes' => [
26
27
'user_credentials' => [
@@ -37,14 +38,15 @@ composer require windhoney/yii2-rest-rbac
37
38
'class' => 'OAuth2\GrantType\AuthorizationCode'
38
39
],
39
40
],
41
+ //选填,oauth2组件版本问题可能导致错误时可添加
40
42
'components' => [
41
- 'request' => function () {
42
- return \filsh\yii2\oauth2server\Request::createFromGlobals();
43
- },
44
- 'response' => [
45
- 'class' => \filsh\yii2\oauth2server\Response::class,
46
- ],
47
- ],
43
+ 'request' => function () {
44
+ return \filsh\yii2\oauth2server\Request::createFromGlobals();
45
+ },
46
+ 'response' => [
47
+ 'class' => \filsh\yii2\oauth2server\Response::class,
48
+ ],
49
+ ],
48
50
]
49
51
],
50
52
'components' => [
@@ -65,6 +67,7 @@ composer require windhoney/yii2-rest-rbac
65
67
]
66
68
```
67
69
* ** 配置权限**
70
+
68
71
``` php
69
72
'as access' => [
70
73
'class' => 'wind\rest\components\AccessControl',
@@ -116,7 +119,13 @@ CREATE TABLE `auth_groups_child` (
116
119
KEY ` user_group_id` (` user_id` ) USING BTREE
117
120
) ENGINE= InnoDB AUTO_INCREMENT= 795 DEFAULT CHARSET= utf8 COMMENT= ' 分组子集' ;
118
121
```
122
+ > ###### 5. 权限控制相关路由可以参考 example/auth_item_sql 其中包含权限相关的insert语句
119
123
124
+ ``` mysql
125
+ INSERT INTO ` auth_item` (` name` , ` type` , ` description` , ` rule_name` , ` parent_name` , ` data` , ` created_at` , ` updated_at` ) VALUES (' /rbac/menu/index' , ' 2' , ' 接口-菜单接口' , NULL , ' 权限控制' , ' ' , ' 1526377735' , ' 1526377269' );
126
+ INSERT INTO ` auth_item` (` name` , ` type` , ` description` , ` rule_name` , ` parent_name` , ` data` , ` created_at` , ` updated_at` ) VALUES (' /rbac/role/index' , ' 2' , ' 接口-角色接口' , NULL , ' 权限控制' , ' ' , ' 1526377735' , ' 1526377269' );
127
+ ......
128
+ ```
120
129
121
130
122
131
* ** 添加路由配置**
0 commit comments