2 Commits

Author SHA1 Message Date
31eed99025 support multiple auth header 2023-11-16 15:48:09 +08:00
6c9eab09e2 record authorization 2023-11-16 15:42:37 +08:00
2 changed files with 6 additions and 5 deletions

10
auth.go
View File

@@ -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

View File

@@ -22,7 +22,6 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s
record.UpstreamID = upstream.ID
record.Response = ""
record.Authorization = upstream.SK
// [TODO] record request body
// reverse proxy