feat: 授权请求头和查询参数支持accessToken接收

This commit is contained in:
TsMask
2024-03-18 11:11:41 +08:00
parent b8244ed242
commit 70388e5fe6
4 changed files with 17 additions and 3 deletions

View File

@@ -1,12 +1,12 @@
# 项目信息
framework:
name: "CN EMS"
version: "2.2401.1"
version: "2.2403.1"
# 应用服务配置
server:
# 服务端口
port: 3030
port: 33030
# 是否开启代理
proxy: false
@@ -100,6 +100,8 @@ cors:
- "Accept-Language"
- "Accept"
- "Range"
# 非标准请求头
- "accessToken",
- "Accesstoken"
- "Operationtype"
# 设置 Access-Control-Expose-Headers 的值

View File

@@ -1,6 +1,6 @@
# 应用服务配置
server:
port: 3030
port: 33030
proxy: true
# security 安全

View File

@@ -19,3 +19,6 @@ const JWT_KEY = "user_id"
// 令牌-JWT标识用户登录账号字段
const JWT_NAME = "user_name"
// NMS北向使用-数据响应字段和请求头授权
const ACCESS_TOKEN = "accessToken"

View File

@@ -66,6 +66,15 @@ func IPAddrLocation(c *gin.Context) (string, string) {
// Authorization 解析请求头
func Authorization(c *gin.Context) string {
// Query请求查询
if authQuery, ok := c.GetQuery(token.ACCESS_TOKEN); ok && authQuery != "" {
return authQuery
}
// Header请求头
if authHeader := c.GetHeader(token.ACCESS_TOKEN); authHeader != "" {
return authHeader
}
// Query请求查询
if authQuery, ok := c.GetQuery(token.RESPONSE_FIELD); ok && authQuery != "" {
return authQuery