Class FederatedUserMapper
java.lang.Object
com.irurueta.authserver.authorization.api.web.social.FederatedUserMapper
Maps the user an external provider described onto the user the rest of the server sees: the principal of the
session, whose name is the local account's username (so it is the
sub of the issued tokens, as it is for
every other way of signing in), whose authorities are the account's own, and which still carries the claims of the
provider (the amr among them).
The principal is stored with the authorization and read back at the token request through a polymorphic allow-list, so every claim is normalised to a JSON-friendly value first: lists are mutable lists (an immutable one is not on the allow-list), instants are epoch seconds and URLs are strings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringClaim of the upstream authentication methods (RFC 8176).(package private) static final StringClaim that says that the provider verified the e-mail address (the standard OIDC one).(package private) static final StringOptional claim of Microsoft Entra ID that says that the owner of the e-mail domain verified the address.static final StringName of the attribute that holds the username of the local account. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanemailVerified(org.springframework.security.oauth2.core.oidc.user.OidcUser user) Tells whether the provider vouches for the e-mail address of an OpenID Connect user.private ObjectNormalises a value.safeClaims(Map<String, Object> claims) Normalises a claim map.org.springframework.security.oauth2.core.oidc.user.OidcUsertoLocalUser(org.springframework.security.oauth2.core.oidc.user.OidcUser upstream, String username, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Maps an OpenID Connect user.org.springframework.security.oauth2.core.user.OAuth2UsertoLocalUser(org.springframework.security.oauth2.core.user.OAuth2User upstream, Collection<String> kept, String email, String username, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Maps an OAuth 2.0 user.upstreamAmr(org.springframework.security.oauth2.core.user.OAuth2User user) Reads theamrvalues the provider reported.
-
Field Details
-
LOCAL_USERNAME_ATTRIBUTE
Name of the attribute that holds the username of the local account.- See Also:
-
AMR_CLAIM
Claim of the upstream authentication methods (RFC 8176).- See Also:
-
EMAIL_VERIFIED_CLAIM
Claim that says that the provider verified the e-mail address (the standard OIDC one).- See Also:
-
ENTRA_DOMAIN_VERIFIED_CLAIM
Optional claim of Microsoft Entra ID that says that the owner of the e-mail domain verified the address.- See Also:
-
-
Constructor Details
-
FederatedUserMapper
public FederatedUserMapper()
-
-
Method Details
-
toLocalUser
public org.springframework.security.oauth2.core.oidc.user.OidcUser toLocalUser(org.springframework.security.oauth2.core.oidc.user.OidcUser upstream, String username, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Maps an OpenID Connect user.- Parameters:
upstream- the user the provider described.username- username of the local account.authorities- authorities of the local account.- Returns:
- a user named after the account, with the claims of the provider.
-
toLocalUser
public org.springframework.security.oauth2.core.user.OAuth2User toLocalUser(org.springframework.security.oauth2.core.user.OAuth2User upstream, Collection<String> kept, String email, String username, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Maps an OAuth 2.0 user. Only the attributes inkeptare carried over (the profile of such a provider may hold nested objects that have no business in the session).- Parameters:
upstream- the user the provider described.kept- names of the attributes to keep.email- verified e-mail address, ornull; it replaces the provider'semail.username- username of the local account.authorities- authorities of the local account.- Returns:
- a user named after the account.
-
emailVerified
public boolean emailVerified(org.springframework.security.oauth2.core.oidc.user.OidcUser user) Tells whether the provider vouches for the e-mail address of an OpenID Connect user. The standardemail_verifiedclaim does (a string"true"too, as Apple sends it); Microsoft Entra ID has no such claim in its default tokens, so its optionalxms_edovclaim counts, and without either the address is not verified: Entra'semailcan be set by a tenant administrator to any value.- Parameters:
user- the user the provider described.- Returns:
truewhen the address is verified.
-
upstreamAmr
Reads theamrvalues the provider reported.- Parameters:
user- the user, as mapped by this class or as the provider described it.- Returns:
- the values, as strings; empty when there is none.
-
safeClaims
Normalises a claim map.- Parameters:
claims- the claims.- Returns:
- a new, mutable map of JSON-friendly values.
-
safe
Normalises a value.- Parameters:
value- the value.- Returns:
- a JSON-friendly equivalent.
-