dix auth checker

This commit is contained in:
wjqserver 2025-04-10 23:07:48 +08:00
parent 005a4543d4
commit d6d54b222f

View file

@ -106,13 +106,15 @@ func NoRouteHandler(cfg *config.Config, limiter *rate.RateLimiter, iplimiter *ra
} }
// 鉴权 // 鉴权
var authcheck bool if cfg.Auth.Enabled {
authcheck, err = auth.AuthHandler(ctx, c, cfg) var authcheck bool
if !authcheck { authcheck, err = auth.AuthHandler(ctx, c, cfg)
//c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) if !authcheck {
c.AbortWithStatusJSON(401, map[string]string{"error": "Unauthorized"}) //c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"})
logWarning("%s %s %s %s %s Auth-Error: %v", c.ClientIP(), c.Method(), rawPath, c.Request.Header.UserAgent(), c.Request.Header.GetProtocol(), err) c.AbortWithStatusJSON(401, map[string]string{"error": "Unauthorized"})
return logWarning("%s %s %s %s %s Auth-Error: %v", c.ClientIP(), c.Method(), rawPath, c.Request.Header.UserAgent(), c.Request.Header.GetProtocol(), err)
return
}
} }
// IP METHOD URL USERAGENT PROTO MATCHES // IP METHOD URL USERAGENT PROTO MATCHES