From d6d54b222f1f6879b9a2c97fdd376dfc888c5509 Mon Sep 17 00:00:00 2001 From: wjqserver <114663932+WJQSERVER@users.noreply.github.com> Date: Thu, 10 Apr 2025 23:07:48 +0800 Subject: [PATCH] dix auth checker --- proxy/handler.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/proxy/handler.go b/proxy/handler.go index 072fd26..f8b998c 100644 --- a/proxy/handler.go +++ b/proxy/handler.go @@ -106,13 +106,15 @@ func NoRouteHandler(cfg *config.Config, limiter *rate.RateLimiter, iplimiter *ra } // 鉴权 - var authcheck bool - authcheck, err = auth.AuthHandler(ctx, c, cfg) - if !authcheck { - //c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) - c.AbortWithStatusJSON(401, map[string]string{"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) - return + if cfg.Auth.Enabled { + var authcheck bool + authcheck, err = auth.AuthHandler(ctx, c, cfg) + if !authcheck { + //c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) + c.AbortWithStatusJSON(401, map[string]string{"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) + return + } } // IP METHOD URL USERAGENT PROTO MATCHES