Skip to content

Commit c609df5

Browse files
committed
Make the Authorization header value prefixes case insensitive
1 parent a6d41a1 commit c609df5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apisprout.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,17 @@ func server(cmd *cobra.Command, args []string) {
517517
if sec.Type == "http" {
518518
// Prefixes for each scheme.
519519
prefixes := map[string]string{
520-
"bearer": "Bearer ",
521-
"basic": "Basic ",
520+
"bearer": "BEARER ",
521+
"basic": "BASIC ",
522522
}
523523
if prefix, ok := prefixes[sec.Scheme]; ok {
524524
auth := req.Header.Get("Authorization")
525525
// If the auth is missing
526526
if len(auth) == 0 {
527527
return ErrMissingAuth
528528
}
529-
// If the auth doesn't have a value or doesn't start with the prefix
530-
if len(auth) <= len(prefix) || !strings.HasPrefix(auth, prefix) {
529+
// If the auth doesn't have a value or doesn't start with the case insensitive prefix
530+
if len(auth) <= len(prefix) || !strings.HasPrefix(strings.ToUpper(auth), prefix) {
531531
return ErrInvalidAuth
532532
}
533533
}

0 commit comments

Comments
 (0)