Class DefaultOidcUser

java.lang.Object
org.springframework.security.oauth2.core.user.DefaultOAuth2User
org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser
All Implemented Interfaces:
Serializable, AuthenticatedPrincipal, ClaimAccessor, OAuth2AuthenticatedPrincipal, IdTokenClaimAccessor, StandardClaimAccessor, OidcUser, OAuth2User

public class DefaultOidcUser extends DefaultOAuth2User implements OidcUser
The default implementation of an OidcUser.

The default claim used for accessing the "name" of the user Principal from getClaims() is IdTokenClaimNames.SUB.

Since:
5.0
See Also:
  • Constructor Details

    • DefaultOidcUser

      public DefaultOidcUser(@Nullable Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken)
      Constructs a DefaultOidcUser using the provided parameters.
      Parameters:
      authorities - the authorities granted to the user, may be null
      idToken - the ID Token containing claims about the user
    • DefaultOidcUser

      public DefaultOidcUser(@Nullable Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, String nameAttributeKey)
      Constructs a DefaultOidcUser using the provided parameters.
      Parameters:
      authorities - the authorities granted to the user, may be null
      idToken - the ID Token containing claims about the user
      nameAttributeKey - the key used to access the user's "name" from DefaultOAuth2User.getAttributes()
    • DefaultOidcUser

      public DefaultOidcUser(@Nullable Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, @Nullable OidcUserInfo userInfo)
      Constructs a DefaultOidcUser using the provided parameters.
      Parameters:
      authorities - the authorities granted to the user, may be null
      idToken - the ID Token containing claims about the user
      userInfo - the UserInfo containing claims about the user, may be null
    • DefaultOidcUser

      public DefaultOidcUser(@Nullable Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, @Nullable OidcUserInfo userInfo, String nameAttributeKey)
      Constructs a DefaultOidcUser using the provided parameters.
      Parameters:
      authorities - the authorities granted to the user, may be null
      idToken - the ID Token containing claims about the user
      userInfo - the UserInfo containing claims about the user, may be null
      nameAttributeKey - the key used to access the user's "name" from DefaultOAuth2User.getAttributes()
  • Method Details