oauth2: allow users to register broken OAuth2 implementations

Fixes golang/oauth2#111.

Change-Id: Iaea8adb038bcff91b4b468b1a3bdaa5c03d7e8e7
Reviewed-on: https://go-review.googlesource.com/16976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Burcu Dogan
2015-11-16 13:49:40 -08:00
parent 2bf5e6e27a
commit 442624c9ec
3 changed files with 24 additions and 0 deletions

View File

@@ -115,6 +115,10 @@ var brokenAuthHeaderProviders = []string{
"https://www.strava.com/oauth/",
}
func RegisterBrokenAuthHeaderProvider(tokenURL string) {
brokenAuthHeaderProviders = append(brokenAuthHeaderProviders, tokenURL)
}
// providerAuthHeaderWorks reports whether the OAuth2 server identified by the tokenURL
// implements the OAuth2 spec correctly
// See https://code.google.com/p/goauth2/issues/detail?id=31 for background.

View File

@@ -10,6 +10,14 @@ import (
"testing"
)
func TestRegisterBrokenAuthHeaderProvider(t *testing.T) {
RegisterBrokenAuthHeaderProvider("https://aaa.com/")
tokenURL := "https://aaa.com/token"
if providerAuthHeaderWorks(tokenURL) {
t.Errorf("URL: %s is a broken provider", tokenURL)
}
}
func Test_providerAuthHeaderWorks(t *testing.T) {
for _, p := range brokenAuthHeaderProviders {
if providerAuthHeaderWorks(p) {