优化:casbin验证优化,在中间件中获取请求的 Path,在CasbinModel定义中直接使用keymatch2进行匹配,减少一次path获取和函数调用。

server/middleware/casbin_rbac.go:18行修改为请求的path作为obj
server/service/system/sys_casbin.go:删掉无用的注册函数
server/resource/rbac_model.conf:验证函数修改为keyMathc2
This commit is contained in:
dyzsoft
2021-11-24 15:23:22 +08:00
parent da64403829
commit 99ae4056bc
3 changed files with 3 additions and 31 deletions
+2 -2
View File
@@ -14,8 +14,8 @@ var casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService
func CasbinHandler() gin.HandlerFunc {
return func(c *gin.Context) {
waitUse, _ := utils.GetClaims(c)
// 获取请求的URI
obj := c.Request.URL.RequestURI()
// 获取请求的PATH
obj := c.Request.URL.Path
// 获取请求方法
act := c.Request.Method
// 获取用户的角色