File tree Expand file tree Collapse file tree 2 files changed +32
-9
lines changed
config/plugin/casbin/webman-permission Expand file tree Collapse file tree 2 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -61,15 +61,16 @@ class Permission implements Bootstrap
6161 public static function start ($ worker )
6262 {
6363 if ($ worker ) {
64- $ configType = config ('plugin.casbin.webman-permission.permission.basic.model.config_type ' );
64+ $ driver = config ('plugin.casbin.webman-permission.permission.default ' );
65+ $ config = config ('plugin.casbin.webman-permission.permission. ' .$ driver );
6566 $ model = new Model ();
66- if ('file ' == $ configType ) {
67- $ model ->loadModel (config ( ' plugin.casbin.webman-permission.permission.basic. model. config_file_path ') );
68- } elseif ('text ' == $ configType ) {
69- $ model ->loadModel (config ( ' plugin.casbin.webman-permission.permission.basic. model. config_text ') );
67+ if ('file ' == $ config [ ' model ' ][ ' config_type ' ] ) {
68+ $ model ->loadModel ($ config[ ' model ' ][ ' config_file_path '] );
69+ } elseif ('text ' == $ config [ ' model ' ][ ' config_type ' ] ) {
70+ $ model ->loadModel ($ config[ ' model ' ][ ' config_text '] );
7071 }
7172 if (is_null (static ::$ _manager )) {
72- static ::$ _manager = new Enforcer ($ model , Container::get (config ( ' plugin.casbin.webman-permission.permission.basic. adapter ') ),false );
73+ static ::$ _manager = new Enforcer ($ model , Container::get ($ config[ ' adapter '] ),false );
7374 }
7475
7576 $ watcher = new RedisWatcher (config ('redis.default ' ));
Original file line number Diff line number Diff line change 66 */
77return [
88 'default ' => 'basic ' ,
9+ // 基础配置
910 'basic ' => [
10- # Model 设置
11+ // 策略模型Model设置
1112 'model ' => [
1213 'config_type ' => 'file ' ,
1314 'config_file_path ' => config_path () . '/plugin/casbin/webman-permission/rbac-model.conf ' ,
1415 'config_text ' => '' ,
1516 ],
16- # 适配器
17+ // 适配器
1718 'adapter ' => Casbin \WebmanPermission \Adapter \DatabaseAdapter::class, // ThinkORM 适配器
1819 // 'adapter' => Casbin\WebmanPermission\Adapter\LaravelDatabaseAdapter::class, // Laravel 适配器
20+ // 数据库设置
1921 'database ' => [
2022 'connection ' => '' ,
2123 'rules_table ' => 'casbin_rule ' ,
2224 'rules_name ' => null
2325 ],
24- ]
26+ ],
27+ // 其他扩展配置
28+ 'abac ' => [
29+ // 策略模型Model设置
30+ 'model ' => [
31+ 'config_type ' => 'file ' ,
32+ 'config_file_path ' => config_path () . '/plugin/casbin/webman-permission/abac-model.conf ' ,
33+ 'config_text ' => '' ,
34+ ],
35+ // 适配器
36+ 'adapter ' => Casbin \WebmanPermission \Adapter \LaravelDatabaseAdapter::class,
37+ // 数据库设置
38+ 'database ' => [
39+ // 数据库连接名称,不填为默认配置
40+ 'connection ' => '' ,
41+ // 策略表名(不含表前缀)
42+ 'rules_table ' => 'casbin_rule ' ,
43+ // 策略表完整名称
44+ 'rules_name ' => null
45+ ],
46+ ],
2547];
You can’t perform that action at this time.
0 commit comments