Class IdpClaimsContributor

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.IdpClaimsContributor
All Implemented Interfaces:
JwtClaimsContributor

@Component @Order(110) public class IdpClaimsContributor extends Object implements JwtClaimsContributor
Adds to the tokens of a user who signed in with an external provider the claim idp (the registration id of the provider). The sub is the local account's username, because the principal's name is (see FederatedUserMapper), so a token of a federated sign-in is indistinguishable from any other in what it says about the user.

When the provider is trusted for its multi-factor authentication and proved it (the strong factor, FederatedFactor.STRONG_AUTHORITY), the upstream amr values are added to the amr claim the MfaClaimsContributor wrote (each value once, so the repeated ones of the factor and of the provider are listed once, and mfa is there exactly once). The acr is not set here: the strong factor is multi-factor alone, so the multi-factor contributor already wrote the multi-factor class, from the same rule the step-up checks use. The upstream amr of a provider that is not trusted is never copied: it would claim a strength the server did not accept.

  • Field Details

    • ORDER

      public static final int ORDER
      Order of the contributor: after the multi-factor one, whose amr it extends.
      See Also:
    • IDP_CLAIM

      public static final String IDP_CLAIM
      Name of the claim that says which provider authenticated the user.
      See Also:
    • userMapper

      private final FederatedUserMapper userMapper
      Reads the upstream amr.
  • Constructor Details

    • IdpClaimsContributor

      public IdpClaimsContributor()
  • Method Details

    • contribute

      public void contribute(org.springframework.security.oauth2.server.authorization.token.OAuth2TokenContext context, Map<String,Object> claims)
      Adds the claims.
      Specified by:
      contribute in interface JwtClaimsContributor
      Parameters:
      context - the token context.
      claims - the claims, which this method extends.
    • existingAmr

      private static List<String> existingAmr(Map<String,Object> claims)
      Reads the amr already in the claims.
      Parameters:
      claims - the claims.
      Returns:
      its values; empty when there is none.