Skip to content

Commit fcb4ad6

Browse files
committed
Fix panic when calling with invalid bearer token
1 parent 2b06ae0 commit fcb4ad6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/middleware.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func AuthenticationRequired(logKey string, accessTokenKey string) gin.HandlerFun
209209
var token *oauth2.Token
210210
auth := c.Request.Header.Get("Authorization")
211211
split := strings.SplitN(auth, " ", 2)
212-
if len(split) == 2 || strings.EqualFold(split[0], "bearer") {
212+
if len(split) == 2 && strings.EqualFold(split[0], "bearer") {
213213

214214
token = &oauth2.Token{
215215
AccessToken: split[1],
@@ -341,4 +341,4 @@ func RequestId() gin.HandlerFunc {
341341
c.Writer.Header().Set("X-Request-Id", requestID)
342342
c.Next()
343343
}
344-
}
344+
}

0 commit comments

Comments
 (0)