support multiple auth header

This commit is contained in:
2023-11-16 15:48:09 +08:00
parent 6c9eab09e2
commit 31eed99025

10
auth.go
View File

@@ -21,10 +21,12 @@ func handleAuth(c *gin.Context) error {
authorization = strings.Trim(authorization[len("Bearer"):], " ") authorization = strings.Trim(authorization[len("Bearer"):], " ")
log.Println("Received authorization", authorization) log.Println("Received authorization", authorization)
if authorization != authConfig.Value { for _, auth := range strings.Split(authConfig.Value, ",") {
err = errors.New("wrong authorization header") if authorization != strings.Trim(auth, " ") {
c.AbortWithError(403, err) err = errors.New("wrong authorization header")
return err c.AbortWithError(403, err)
return err
}
} }
return nil return nil