oauth2: ensure case sensitivity for Bearer, MAC, and Basic in auth header

Fixes #113

Change-Id: Id2ba98809a536f1dc1fab5b30c49aeedd2fe4125
Reviewed-on: https://go-review.googlesource.com/9852
Reviewed-by: Burcu Dogan <jbd@google.com>
This commit is contained in:
Andrew Etter
2015-05-10 16:33:37 -04:00
committed by Burcu Dogan
parent f98d016087
commit 36ff901f7b
2 changed files with 43 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ package oauth2
import (
"net/http"
"net/url"
"strings"
"time"
"golang.org/x/net/context"
@@ -53,6 +54,15 @@ type Token struct {
// Type returns t.TokenType if non-empty, else "Bearer".
func (t *Token) Type() string {
if strings.EqualFold(t.TokenType, "bearer") {
return "Bearer"
}
if strings.EqualFold(t.TokenType, "mac") {
return "MAC"
}
if strings.EqualFold(t.TokenType, "basic") {
return "Basic"
}
if t.TokenType != "" {
return t.TokenType
}