Class ClientRegistrationMapper
java.lang.Object
com.irurueta.authserver.authorization.api.web.social.ClientRegistrationMapper
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;
EntraIssuerValidatorchecks 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:emailscope the verified primary address needs.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringBase URL of Sign in with Apple.(package private) static final StringScope Sign in with Apple uses to hand over the name of the user (it has noprofilescope).(package private) static final StringBase URL of Microsoft Entra ID.(package private) static final StringOAuth scope that lets GitHub's API list the e-mail addresses of the user.(package private) static final StringOAuth scope that lets GitHub's API read the profile of the user.(package private) static final StringOIDC UserInfo endpoint of Microsoft.static final StringRedirect URI template of every registration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.springframework.security.oauth2.client.registration.ClientRegistrationapple(SocialProperties.Provider settings) Builds the Sign in with Apple registration.private static org.springframework.security.oauth2.client.registration.ClientRegistrationmicrosoft(SocialProperties.Provider settings) Builds the Microsoft Entra ID registration, without an issuer (see the class description).org.springframework.security.oauth2.client.registration.ClientRegistrationtoRegistration(IdentityProvider provider, SocialProperties.Provider settings) Maps one provider.List<org.springframework.security.oauth2.client.registration.ClientRegistration> toRegistrations(SocialProperties properties) Maps the enabled providers.
-
Field Details
-
REDIRECT_URI
Redirect URI template of every registration.- See Also:
-
ENTRA_BASE_URL
Base URL of Microsoft Entra ID.- See Also:
-
APPLE_BASE_URL
Base URL of Sign in with Apple.- See Also:
-
GITHUB_EMAIL_SCOPE
OAuth scope that lets GitHub's API list the e-mail addresses of the user.- See Also:
-
GITHUB_USER_SCOPE
OAuth scope that lets GitHub's API read the profile of the user.- See Also:
-
APPLE_NAME_SCOPE
Scope Sign in with Apple uses to hand over the name of the user (it has noprofilescope).- See Also:
-
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.
-