Merge remote-tracking branch 'origin/main' into multi-tenant
This commit is contained in:
@@ -24,6 +24,16 @@ import (
|
||||
// 请将中间件放在最前置,对请求优先处理
|
||||
func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// 登录认证,默认打开
|
||||
enable := true
|
||||
if v := config.Get("user.cryptoApi"); v != nil && enable {
|
||||
enable = v.(bool)
|
||||
}
|
||||
if !enable {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
// 请求解密时对请求data注入
|
||||
if requestDecrypt {
|
||||
method := c.Request.Method
|
||||
|
||||
@@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"be.ems/src/framework/config"
|
||||
AdminConstants "be.ems/src/framework/constants/admin"
|
||||
commonConstants "be.ems/src/framework/constants/common"
|
||||
"be.ems/src/framework/i18n"
|
||||
@@ -36,6 +37,22 @@ var URL_WHITE_LIST = []string{
|
||||
// 同时匹配其中权限 "matchPerms": {"xxx"},
|
||||
func PreAuthorize(options map[string][]string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// 登录认证,默认打开
|
||||
enable := true
|
||||
if v := config.Get("user.loginAuth"); v != nil {
|
||||
enable = v.(bool)
|
||||
}
|
||||
if !enable {
|
||||
loginUser, _ := ctxUtils.LoginUser(c)
|
||||
loginUser.UserID = "2"
|
||||
loginUser.User.UserID = "2"
|
||||
loginUser.User.UserName = "admin"
|
||||
loginUser.User.NickName = "admin"
|
||||
c.Set(commonConstants.CTX_LOGIN_USER, loginUser)
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
language := ctxUtils.AcceptLanguage(c)
|
||||
|
||||
requestURI := c.Request.RequestURI
|
||||
|
||||
Reference in New Issue
Block a user