mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-29 15:38:52 +00:00
fix(idp): do not call userinfo when mapping from ID token is configured (#7696)
* fix(idp): do not call userinfo when mapping from ID token is configured This change prevents the call of the Userinfo endpoint of a OIDC IDP if the IDP is configured to use the ID token for user information instead. A unit test has been added to confirm the corrected behavior. Closes #7373 * video for e2e --------- Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
f862e43ede
commit
9b3f3e4cd9
@@ -38,17 +38,20 @@ func (s *Session) FetchUser(ctx context.Context) (user idp.User, err error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
info, err := rp.Userinfo[*oidc.UserInfo](ctx,
|
||||
s.Tokens.AccessToken,
|
||||
s.Tokens.TokenType,
|
||||
s.Tokens.IDTokenClaims.GetSubject(),
|
||||
s.Provider.RelyingParty,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var info *oidc.UserInfo
|
||||
if s.Provider.useIDToken {
|
||||
info = s.Tokens.IDTokenClaims.GetUserInfo()
|
||||
} else {
|
||||
info, err = rp.Userinfo[*oidc.UserInfo](ctx,
|
||||
s.Tokens.AccessToken,
|
||||
s.Tokens.TokenType,
|
||||
s.Tokens.IDTokenClaims.GetSubject(),
|
||||
s.Provider.RelyingParty,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
u := s.Provider.userInfoMapper(info)
|
||||
return u, nil
|
||||
|
||||
Reference in New Issue
Block a user