Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions providers/auth0/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type auth0UserResp struct {
Email string `json:"email"`
UserID string `json:"sub"`
AvatarURL string `json:"picture"`
FirstName string `json:"given_name"`
LastName string `json:"family_name"`
}

// New creates a new Auth0 provider and sets up important connection details.
Expand Down Expand Up @@ -162,6 +164,8 @@ func userFromReader(r io.Reader, user *goth.User) error {
user.NickName = u.NickName
user.UserID = u.UserID
user.AvatarURL = u.AvatarURL
user.FirstName = u.FirstName
user.LastName = u.LastName
user.RawData = rawData
return nil
}
Expand Down
15 changes: 12 additions & 3 deletions providers/auth0/auth0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func Test_FetchUser(t *testing.T) {
"email": "test.account@userinfo.com",
"clientID": "q2hnj2iu...",
"updated_at": "2016-12-05T15:15:40.545Z",
"name": "test.account@userinfo.com",
"name": "Test User",
"given_name": "Test",
"family_name": "User",
"picture": "https://s.gravatar.com/avatar/dummy.png",
"user_id": "auth0|58454...",
"nickname": "test.account",
Expand All @@ -91,9 +93,16 @@ func Test_FetchUser(t *testing.T) {
a.Equal(u.Email, "test.account@userinfo.com")
a.Equal(u.UserID, "auth0|58454...")
a.Equal(u.NickName, "test.account")
a.Equal(u.Name, "test.account@userinfo.com")
a.Equal(u.Name, "Test User")
// Auth0 returns OIDC-standard given_name/family_name claims (#430) — they
// should populate goth.User.FirstName/LastName, matching how the Google
// provider handles the same claims.
a.Equal("Test", u.FirstName)
a.Equal("User", u.LastName)
a.Equal("token", u.AccessToken)

// email_verified isn't mapped to a typed field but must remain in RawData
// so callers that need it can still read it.
a.Equal(false, u.RawData["email_verified"])
}

func provider() *auth0.Provider {
Expand Down