Skip to content

Commit

Permalink
authenticate: remove extra UpdateUserInfo() call
Browse files Browse the repository at this point in the history
The buildIdentityProfile() method is called only from
Authenticate.getOAuthCallback(), which has previously called
Authenticator.Authenticate(). It looks like all implementations of the
Authenticator interface already call UpdateUserInfo(), so we shouldn't
need to call UpdateUserInfo() a second time from buildIdentityProfile().

This should simplify the code a little and provide a slight performance
improvement (by avoiding one network request).
  • Loading branch information
kenjenkins committed Dec 4, 2023
1 parent 1780fef commit 59447ca
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions authenticate/identity_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,8 @@ func (a *Authenticate) buildIdentityProfile(
claims identity.SessionClaims,
oauthToken *oauth2.Token,
) (*identitypb.Profile, error) {
options := a.options.Load()
idpID := r.FormValue(urlutil.QueryIdentityProviderID)

authenticator, err := a.cfg.getIdentityProvider(options, idpID)
if err != nil {
return nil, fmt.Errorf("authenticate: error getting identity provider authenticator: %w", err)
}

err = authenticator.UpdateUserInfo(ctx, oauthToken, &claims)
if err != nil {
return nil, fmt.Errorf("authenticate: error retrieving user info: %w", err)
}

rawIDToken := []byte(claims.RawIDToken)
rawOAuthToken, err := json.Marshal(oauthToken)
if err != nil {
Expand Down

0 comments on commit 59447ca

Please sign in to comment.