From 31eed99025c2f5ce5e461382b0a864ce313e590b Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Thu, 16 Nov 2023 15:48:09 +0800 Subject: [PATCH] support multiple auth header --- auth.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/auth.go b/auth.go index a386b3c..a57b615 100644 --- a/auth.go +++ b/auth.go @@ -21,10 +21,12 @@ func handleAuth(c *gin.Context) error { authorization = strings.Trim(authorization[len("Bearer"):], " ") log.Println("Received authorization", authorization) - if authorization != authConfig.Value { - err = errors.New("wrong authorization header") - c.AbortWithError(403, err) - return err + for _, auth := range strings.Split(authConfig.Value, ",") { + if authorization != strings.Trim(auth, " ") { + err = errors.New("wrong authorization header") + c.AbortWithError(403, err) + return err + } } return nil