Merge pull request #466 from zlabjp/update-go-oidc

vendor: update go-oidc to add support for Azure AD
This commit is contained in:
Eric Chiang 2016-06-13 09:28:29 -07:00 committed by GitHub
commit ea2f0a3264
4 changed files with 30 additions and 16 deletions

6
glide.lock generated
View file

@ -1,10 +1,10 @@
hash: 7e7b258be2aa7e03d1bb15c96f856a9b7982d850a1faeba699a0b11bcb0c6936
updated: 2016-05-27T00:22:02.656877293+02:00
hash: af5ee807138ecd53eebc54567b4dcd66e3a6ddc7d758fb9f34e6e3eb13b20cf2
updated: 2016-06-13T10:58:04.608971954+09:00
imports:
- name: github.com/andybalholm/cascadia
version: 6122e68c2642b7b75c538a63b15168c6c80fb757
- name: github.com/coreos/go-oidc
version: e6174c764e906bd60c76fdfc33faf5e0bdc875d6
version: 8ae400b75540a4f57ec549a89b3e9d994c636f2a
subpackages:
- http
- jose

View file

@ -5,7 +5,7 @@ import:
- package: github.com/andybalholm/cascadia
version: 6122e68c2642b7b75c538a63b15168c6c80fb757
- package: github.com/coreos/go-oidc
version: e6174c764e906bd60c76fdfc33faf5e0bdc875d6
version: 8ae400b75540a4f57ec549a89b3e9d994c636f2a
subpackages:
- http
- jose

View file

@ -338,7 +338,7 @@ func parseTokenResponse(resp *http.Response) (result TokenResponse, err error) {
RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"`
State string `json:"state"`
ExpiresIn int `json:"expires_in"`
ExpiresIn json.Number `json:"expires_in"` // Azure AD returns string
Expires int `json:"expires"`
Error string `json:"error"`
Desc string `json:"error_description"`
@ -355,10 +355,10 @@ func parseTokenResponse(resp *http.Response) (result TokenResponse, err error) {
result.IDToken = r.IDToken
result.RefreshToken = r.RefreshToken
result.Scope = r.Scope
if r.ExpiresIn == 0 {
if expiresIn, err := r.ExpiresIn.Int64(); err != nil {
result.Expires = r.Expires
} else {
result.Expires = r.ExpiresIn
result.Expires = int(expiresIn)
}
}
return

View file

@ -438,6 +438,20 @@ func TestParseTokenResponse(t *testing.T) {
RefreshToken: "spam",
},
},
{
// Azure AD returns "expires_in" value as string
resp: response{
body: `{"access_token":"foo","id_token":"bar","expires_in":"300","token_type":"bearer","refresh_token":"spam"}`,
contentType: "application/json; charset=utf-8",
},
wantResp: TokenResponse{
AccessToken: "foo",
IDToken: "bar",
Expires: 300,
TokenType: "bearer",
RefreshToken: "spam",
},
},
{
resp: response{
body: `{"access_token":"foo","id_token":"bar","expires":200,"token_type":"bearer","refresh_token":"spam"}`,