Skip to content

Commit c78c418

Browse files
committed
fix: restful-model.conf 适配器
1 parent 49cf201 commit c78c418

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/Model/RuleModel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class RuleModel extends Model implements Arrayable
3535
];
3636

3737
/** @var string|null $driver */
38-
protected ?string $driver;
38+
protected ?string $driver;
3939

4040
/**
4141
* 架构函数
@@ -61,7 +61,7 @@ public function __construct(array $data = [], ?string $driver = null)
6161
*/
6262
protected function config(string $key = null, $default = null)
6363
{
64-
$driver = $this->driver ?: config('plugin.casbin.webman-permission.permission.default');
64+
$driver = $this->driver ?? config('plugin.casbin.webman-permission.permission.default');
6565
return config('plugin.casbin.webman-permission.permission.' . $driver . '.' . $key, $default);
6666
}
6767
}

src/config/plugin/casbin/webman-permission/permission.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
return [
88
'default' => 'basic',
9-
// 基础配置
9+
// 默认配置
1010
'basic' => [
1111
// 策略模型Model设置
1212
'model' => [
@@ -25,4 +25,17 @@
2525
],
2626
],
2727
// 其他扩展配置,只需要按照基础配置一样,复制一份,指定相关策略模型和适配器即可
28+
'restful' => [
29+
'model' => [
30+
'config_type' => 'file',
31+
'config_file_path' => config_path() . '/plugin/casbin/webman-permission/restful-model.conf',
32+
'config_text' => '',
33+
],
34+
'adapter' => Casbin\WebmanPermission\Adapter\DatabaseAdapter::class, // ThinkORM 适配器
35+
'database' => [
36+
'connection' => '',
37+
'rules_table' => 'restful_casbin_rule',
38+
'rules_name' => null
39+
],
40+
],
2841
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[request_definition]
2+
r = sub, obj, act
3+
4+
[policy_definition]
5+
p = sub, obj, act
6+
7+
[policy_effect]
8+
e = some(where (p.eft == allow))
9+
10+
[matchers]
11+
m = r.sub == p.sub && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act)

0 commit comments

Comments
 (0)