update: User transmission interface encryption
This commit is contained in:
@@ -41,7 +41,10 @@ func AuthMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
loginType := claims["LoginType"].(string)
|
||||
loginType := ""
|
||||
if claims["LoginType"] != nil {
|
||||
loginType = claims["LoginType"].(string)
|
||||
}
|
||||
// get user id from token
|
||||
userId := int64(claims["UserId"].(float64))
|
||||
// get session id from token
|
||||
|
||||
@@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -37,6 +38,8 @@ func DeviceMiddleware(srvCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), constant.LoginType, loginType))
|
||||
|
||||
if !srvCtx.Config.Device.Enable || srvCtx.Config.Device.SecuritySecret == "" {
|
||||
c.Next()
|
||||
return
|
||||
@@ -123,8 +126,6 @@ func (rw *ResponseWriter) Decrypt() bool {
|
||||
rw.c.Request.URL.RawQuery = query.Encode()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
//判断body是否存在数据,存在就尝试解密,并设置回去
|
||||
|
||||
Reference in New Issue
Block a user