update: User transmission interface encryption

This commit is contained in:
EUForest
2025-10-12 19:10:52 +08:00
parent 3efa68d3ff
commit 8c776cdbac
13 changed files with 87 additions and 29 deletions
+4 -1
View File
@@ -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 -2
View File
@@ -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是否存在数据,存在就尝试解密,并设置回去