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
6 changes: 3 additions & 3 deletions internal/api/external_google_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

const (
googleUser string = `{"id":"googleTestId","name":"Google Test","picture":"http://example.com/avatar","email":"google@example.com","verified_email":true}}`
googleUserWrongEmail string = `{"id":"googleTestId","name":"Google Test","picture":"http://example.com/avatar","email":"other@example.com","verified_email":true}}`
googleUserNoEmail string = `{"id":"googleTestId","name":"Google Test","picture":"http://example.com/avatar","verified_email":false}}`
googleUser string = `{"id":"googleTestId","name":"Google Test","given_name":"Google","family_name":"Test","picture":"http://example.com/avatar","email":"google@example.com","verified_email":true,"locale":"en"}`
googleUserWrongEmail string = `{"id":"googleTestId","name":"Google Test","given_name":"Google","family_name":"Test","picture":"http://example.com/avatar","email":"other@example.com","verified_email":true,"locale":"en"}`
googleUserNoEmail string = `{"id":"googleTestId","name":"Google Test","given_name":"Google","family_name":"Test","picture":"http://example.com/avatar","verified_email":false}`
)

func (ts *ExternalTestSuite) TestSignupExternalGoogle() {
Expand Down
6 changes: 6 additions & 0 deletions internal/api/provider/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ type googleUser struct {
Subject string `json:"sub"`
Issuer string `json:"iss"`
Name string `json:"name"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
AvatarURL string `json:"picture"`
Email string `json:"email"`
VerifiedEmail bool `json:"verified_email"`
EmailVerified bool `json:"email_verified"`
HostedDomain string `json:"hd"`
Locale string `json:"locale"`
}

func (u googleUser) IsEmailVerified() bool {
Expand Down Expand Up @@ -122,9 +125,12 @@ func (g googleProvider) GetUserData(ctx context.Context, tok *oauth2.Token) (*Us
Issuer: internalUserInfoEndpointGoogle,
Subject: u.ID,
Name: u.Name,
GivenName: u.GivenName,
FamilyName: u.FamilyName,
Picture: u.AvatarURL,
Email: u.Email,
EmailVerified: u.IsEmailVerified(),
Locale: u.Locale,

// To be deprecated
AvatarURL: u.AvatarURL,
Expand Down
13 changes: 9 additions & 4 deletions internal/api/provider/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ func parseGoogleIDToken(token *oidc.IDToken) (*oidc.IDToken, *UserProvidedData,
}

data.Metadata = &Claims{
Issuer: claims.Issuer,
Subject: claims.Subject,
Name: claims.Name,
Picture: claims.AvatarURL,
Issuer: claims.Issuer,
Subject: claims.Subject,
Name: claims.Name,
GivenName: claims.GivenName,
FamilyName: claims.FamilyName,
Picture: claims.AvatarURL,
Email: claims.Email,
EmailVerified: claims.IsEmailVerified(),
Locale: claims.Locale,

// To be deprecated
AvatarURL: claims.AvatarURL,
Expand Down