Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/azureadv2: retrieve ID token from response if available #489

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions providers/azureadv2/azureadv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {

err = userFromReader(response.Body, &user)
user.AccessToken = msSession.AccessToken
user.IDToken = msSession.IDToken
user.RefreshToken = msSession.RefreshToken
user.ExpiresAt = msSession.ExpiresAt
return user, err
Expand Down
4 changes: 4 additions & 0 deletions providers/azureadv2/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type Session struct {
AuthURL string `json:"au"`
AccessToken string `json:"at"`
IDToken string `json:"it"`
RefreshToken string `json:"rt"`
ExpiresAt time.Time `json:"exp"`
}
Expand Down Expand Up @@ -41,6 +42,9 @@ func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string,
s.AccessToken = token.AccessToken
s.RefreshToken = token.RefreshToken
s.ExpiresAt = token.Expiry
if idTok, ok := token.Extra("id_token").(string); ok {
s.IDToken = idTok
}

return token.AccessToken, err
}
Expand Down
2 changes: 1 addition & 1 deletion providers/azureadv2/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Test_ToJSON(t *testing.T) {
s := &azureadv2.Session{}

data := s.Marshal()
a.Equal(`{"au":"","at":"","rt":"","exp":"0001-01-01T00:00:00Z"}`, data)
a.Equal(`{"au":"","at":"","it":"","rt":"","exp":"0001-01-01T00:00:00Z"}`, data)
}

func Test_String(t *testing.T) {
Expand Down