Class ClientRegistrationMapper

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.ClientRegistrationMapper

@Component public class ClientRegistrationMapper extends Object
Maps the settings of the enabled providers onto the client registrations Spring Security's oauth2Login needs. The client secret of every registration comes from SocialProperties (so from the environment), and the Apple registration carries none: its secret is a JWT generated for each token request (AppleClientSecretGenerator).
  • Google is an OpenID Connect provider with the framework's defaults;
  • Microsoft Entra ID is registered without an issuer: a multi-tenant application's tokens carry the issuer of the tenant the user belongs to, so the framework's single issuer comparison would reject them all; EntraIssuerValidator checks the issuer against the token's tenant instead;
  • Apple is an OpenID Connect provider without a UserInfo endpoint, whose client authentication is the signed secret posted with the other parameters;
  • GitHub is plain OAuth 2.0 (no ID token): the user is read from its API, with the user:email scope the verified primary address needs.
  • Field Details

    • REDIRECT_URI

      public static final String REDIRECT_URI
      Redirect URI template of every registration.
      See Also:
    • ENTRA_BASE_URL

      static final String ENTRA_BASE_URL
      Base URL of Microsoft Entra ID.
      See Also:
    • APPLE_BASE_URL

      static final String APPLE_BASE_URL
      Base URL of Sign in with Apple.
      See Also:
    • GITHUB_EMAIL_SCOPE

      static final String GITHUB_EMAIL_SCOPE
      OAuth scope that lets GitHub's API list the e-mail addresses of the user.
      See Also:
    • GITHUB_USER_SCOPE

      static final String GITHUB_USER_SCOPE
      OAuth scope that lets GitHub's API read the profile of the user.
      See Also:
    • APPLE_NAME_SCOPE

      static final String APPLE_NAME_SCOPE
      Scope Sign in with Apple uses to hand over the name of the user (it has no profile scope).
      See Also:
    • MICROSOFT_USER_INFO_URI

      static final String MICROSOFT_USER_INFO_URI
      OIDC UserInfo endpoint of Microsoft.
      See Also:
  • Constructor Details

    • ClientRegistrationMapper

      public ClientRegistrationMapper()
  • Method Details

    • toRegistrations

      public List<org.springframework.security.oauth2.client.registration.ClientRegistration> toRegistrations(SocialProperties properties)
      Maps the enabled providers.
      Parameters:
      properties - settings of the providers.
      Returns:
      one registration per enabled provider, in the order of IdentityProvider; empty when none is enabled.
    • toRegistration

      public org.springframework.security.oauth2.client.registration.ClientRegistration toRegistration(IdentityProvider provider, SocialProperties.Provider settings)
      Maps one provider.
      Parameters:
      provider - the provider.
      settings - its settings.
      Returns:
      the registration.
    • microsoft

      private static org.springframework.security.oauth2.client.registration.ClientRegistration microsoft(SocialProperties.Provider settings)
      Builds the Microsoft Entra ID registration, without an issuer (see the class description).
      Parameters:
      settings - settings of the provider.
      Returns:
      the registration.
    • apple

      private static org.springframework.security.oauth2.client.registration.ClientRegistration apple(SocialProperties.Provider settings)
      Builds the Sign in with Apple registration. Its client secret is empty here: the token request carries the signed JWT instead.
      Parameters:
      settings - settings of the provider.
      Returns:
      the registration.