Browse Source

增加开发者模式 配置文件env 修改为develop就可跳过鉴权

main
QM303176530 5 years ago
parent
commit
aa6821e6b7
  1. 2
      server/config.yaml
  2. 3
      server/middleware/casbin_rcba.go

2
server/config.yaml

@ -33,7 +33,7 @@ redis:
# system configuration
system:
use-multipoint: false
env: 'develop'
env: 'public' # Change to "develop" to skip authentication for development mode
addr: 8888
# captcha configuration

3
server/middleware/casbin_rcba.go

@ -1,6 +1,7 @@
package middleware
import (
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/model/request"
"gin-vue-admin/service"
@ -20,7 +21,7 @@ func CasbinHandler() gin.HandlerFunc {
sub := waitUse.AuthorityId
e := service.Casbin()
//判断策略中是否存在
if e.Enforce(sub, obj, act) {
if global.GVA_CONFIG.System.Env == "develop" || e.Enforce(sub, obj, act) {
c.Next()
} else {
response.Result(response.ERROR, gin.H{}, "权限不足", c)

Loading…
Cancel
Save