File tree Expand file tree Collapse file tree 8 files changed +35
-39
lines changed
web/src/view/systemTools/system Expand file tree Collapse file tree 8 files changed +35
-39
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,6 @@ email:
35
35
secret : ' xxx'
36
36
nickname : ' test'
37
37
38
- # casbin configuration
39
- casbin :
40
- model-path : ' ./resource/rbac_model.conf'
41
-
42
38
# system configuration
43
39
system :
44
40
env : ' public' # Change to "develop" to skip authentication for development mode
Original file line number Diff line number Diff line change @@ -35,10 +35,6 @@ email:
35
35
secret : ' xxx'
36
36
nickname : ' test'
37
37
38
- # casbin configuration
39
- casbin :
40
- model-path : ' ./resource/rbac_model.conf'
41
-
42
38
# system configuration
43
39
system :
44
40
env : ' public' # Change to "develop" to skip authentication for development mode
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ type Server struct {
5
5
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
6
6
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
7
7
Email Email `mapstructure:"email" json:"email" yaml:"email"`
8
- Casbin Casbin `mapstructure:"casbin" json:"casbin" yaml:"casbin"`
9
8
System System `mapstructure:"system" json:"system" yaml:"system"`
10
9
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
11
10
// auto
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -35,9 +35,17 @@ func (apiService *ApiService) CreateApi(api system.SysApi) (err error) {
35
35
//@return: err error
36
36
37
37
func (apiService * ApiService ) DeleteApi (api system.SysApi ) (err error ) {
38
- err = global .GVA_DB .Delete (& api ).Error
39
- CasbinServiceApp .ClearCasbin (1 , api .Path , api .Method )
40
- return err
38
+ var entity system.SysApi
39
+ err = global .GVA_DB .Where ("id = ?" , api .ID ).First (& entity ).Error // 根据id查询api记录
40
+ if errors .Is (err , gorm .ErrRecordNotFound ) { // api记录不存在
41
+ return err
42
+ }
43
+ err = global .GVA_DB .Delete (& entity ).Error
44
+ if err != nil {
45
+ return err
46
+ }
47
+ CasbinServiceApp .ClearCasbin (1 , entity .Path , entity .Method )
48
+ return nil
41
49
}
42
50
43
51
//@author: [piexlmax](https://github.com/piexlmax)
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package system
2
2
3
3
import (
4
4
"errors"
5
+ "github.com/casbin/casbin/v2/model"
6
+ "go.uber.org/zap"
5
7
"sync"
6
8
7
9
"github.com/casbin/casbin/v2"
92
94
func (casbinService * CasbinService ) Casbin () * casbin.SyncedEnforcer {
93
95
once .Do (func () {
94
96
a , _ := gormadapter .NewAdapterByDB (global .GVA_DB )
95
- syncedEnforcer , _ = casbin .NewSyncedEnforcer (global .GVA_CONFIG .Casbin .ModelPath , a )
97
+ text := `
98
+ [request_definition]
99
+ r = sub, obj, act
100
+
101
+ [policy_definition]
102
+ p = sub, obj, act
103
+
104
+ [role_definition]
105
+ g = _, _
106
+
107
+ [policy_effect]
108
+ e = some(where (p.eft == allow))
109
+
110
+ [matchers]
111
+ m = r.sub == p.sub && keyMatch2(r.obj,p.obj) && r.act == p.act
112
+ `
113
+ m , err := model .NewModelFromString (text )
114
+ if err != nil {
115
+ zap .L ().Error ("字符串加载模型失败!" , zap .Error (err ))
116
+ return
117
+ }
118
+ syncedEnforcer , _ = casbin .NewSyncedEnforcer (m , a )
96
119
})
97
120
_ = syncedEnforcer .LoadPolicy ()
98
121
return syncedEnforcer
Original file line number Diff line number Diff line change 120
120
<el-button @click =" email" >测试邮件</el-button >
121
121
</el-form-item >
122
122
</el-collapse-item >
123
- <el-collapse-item title =" casbin配置" name =" 6" >
124
- <el-form-item label =" 模型地址" >
125
- <el-input v-model =" config.casbin['model-path']" />
126
- </el-form-item >
127
- </el-collapse-item >
128
-
129
123
<el-collapse-item title =" 验证码配置" name =" 7" >
130
124
<el-form-item label =" 字符长度" >
131
125
<el-input v-model.number =" config.captcha['key-long']" />
@@ -370,7 +364,6 @@ const config = ref({
370
364
' iplimit-time' : 0
371
365
},
372
366
jwt: {},
373
- casbin: {},
374
367
mysql: {},
375
368
pgsql: {},
376
369
excel: {},
You can’t perform that action at this time.
0 commit comments