diff --git a/server/oauth2_test.go b/server/oauth2_test.go index 1d9fa083..997373fc 100644 --- a/server/oauth2_test.go +++ b/server/oauth2_test.go @@ -342,6 +342,7 @@ func TestValidRedirectURI(t *testing.T) { redirectURI: "http://foo.com/bar/baz", wantValid: false, }, + // These special desktop + device + localhost URIs are allowed by default. { client: storage.Client{ Public: true, @@ -349,6 +350,13 @@ func TestValidRedirectURI(t *testing.T) { redirectURI: "urn:ietf:wg:oauth:2.0:oob", wantValid: true, }, + { + client: storage.Client{ + Public: true, + }, + redirectURI: "/device/callback", + wantValid: true, + }, { client: storage.Client{ Public: true, @@ -387,6 +395,48 @@ func TestValidRedirectURI(t *testing.T) { redirectURI: "http://foo.com/bar/baz", wantValid: false, }, + // These special desktop + device + localhost URIs are allowed even when RedirectURIs is non-empty. + { + client: storage.Client{ + Public: true, + RedirectURIs: []string{"http://foo.com/bar"}, + }, + redirectURI: "urn:ietf:wg:oauth:2.0:oob", + wantValid: true, + }, + { + client: storage.Client{ + Public: true, + RedirectURIs: []string{"http://foo.com/bar"}, + }, + redirectURI: "/device/callback", + wantValid: true, + }, + { + client: storage.Client{ + Public: true, + RedirectURIs: []string{"http://foo.com/bar"}, + }, + redirectURI: "http://localhost:8080/", + wantValid: true, + }, + { + client: storage.Client{ + Public: true, + RedirectURIs: []string{"http://foo.com/bar"}, + }, + redirectURI: "http://localhost:991/bar", + wantValid: true, + }, + { + client: storage.Client{ + Public: true, + RedirectURIs: []string{"http://foo.com/bar"}, + }, + redirectURI: "http://localhost", + wantValid: true, + }, + // Non-localhost URIs are not allowed implicitly. { client: storage.Client{ Public: true,