fix(auth): remove access_token query parameter from AuthMiddleware
移除认证中间件中 access_token 查询参数的回退逻辑,防止令牌通过 URL 暴露 - 仅支持 Authorization: Bearer 请求头认证 - 防止令牌被反向代理日志、浏览器历史、监控系统等捕获 - 前端已使用安全的头部认证方式
This commit is contained in:
@@ -18,8 +18,6 @@ func AuthMiddleware(cfg config.Config) gin.HandlerFunc {
|
||||
tokenValue := ""
|
||||
if strings.HasPrefix(value, "Bearer ") {
|
||||
tokenValue = strings.TrimPrefix(value, "Bearer ")
|
||||
} else {
|
||||
tokenValue = strings.TrimSpace(c.Query("access_token"))
|
||||
}
|
||||
if tokenValue == "" {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "missing bearer token"})
|
||||
|
||||
Reference in New Issue
Block a user