Skip to content
Snippets Groups Projects
Commit acc016cf authored by Jano Hendriks's avatar Jano Hendriks
Browse files

Allow uncapitalized authorization header

parent d042b533
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,10 @@ func GenerateNewApiKey() string { ...@@ -22,7 +22,10 @@ func GenerateNewApiKey() string {
// GetApiKeyFromHeaders checks if a bearer token is passed as part of the Authorization header and returns that key // GetApiKeyFromHeaders checks if a bearer token is passed as part of the Authorization header and returns that key
func GetApiKeyFromHeaders(headers map[string]string) string { func GetApiKeyFromHeaders(headers map[string]string) string {
key := headers["Authorization"] key := headers["authorization"]
if key == "" {
key = headers["Authorization"]
}
if strings.HasPrefix(strings.ToLower(key), "bearer ") { if strings.HasPrefix(strings.ToLower(key), "bearer ") {
key = strings.TrimPrefix(strings.ToLower(key), "bearer") key = strings.TrimPrefix(strings.ToLower(key), "bearer")
return strings.TrimSpace(key) return strings.TrimSpace(key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment