Class SocialChainCustomizer

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.SocialChainCustomizer
All Implemented Interfaces:
LoginChainCustomizer

public class SocialChainCustomizer extends Object implements LoginChainCustomizer
Customizes the login/UI chain with the sign-in with external providers: http.oauth2Login(...) with the client registrations of the configured providers, the user services that resolve the local account, the success handler that grants the federated factor and, for Apple, the signed client secret and the form post callback.

The endpoints of the framework (/oauth2/authorization/* starts a sign-in, /login/oauth2/code/* receives the provider's answer) are public. The login page is the server's own, so the provider's page is never chosen automatically even when one provider is configured. Apple posts its answer to the callback from another site, so that one callback is exempt from CSRF protection (the state of the authorization request protects it) and the session cookie must be sent on a cross-site post (see the documentation of the social login). The same endpoints serve the explicit link flow of the identities page: the success and failure handlers tell a link apart.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
    Whether Apple is configured, which posts its answer to the callback.
    (package private) static final String
    Pattern of the endpoints that start a sign-in.
    private final org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver
    Builds the authorization requests.
    (package private) static final String
    Pattern of the endpoints that receive the provider's answer.
    private final org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
    Registrations of the configured providers.
    private final org.springframework.security.web.authentication.AuthenticationFailureHandler
    Sends a refused link back to the identities page, any other failure to the login page.
    Resolves the account of an OAuth 2.0 sign-in.
    Resolves the account of an OpenID Connect sign-in.
    static final int
    Order of the customizer: after the phone page one.
    private final org.springframework.security.web.context.SecurityContextRepository
    Saves the security context of the sign-in.
    private final org.springframework.security.web.authentication.AuthenticationSuccessHandler
    Grants the federated factor and resumes the saved request, or completes a link.
    private final org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient<org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest>
    Exchanges the authorization code for tokens.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    customize(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
    Customizes the login/UI chain.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ORDER

      public static final int ORDER
      Order of the customizer: after the phone page one.
      See Also:
    • AUTHORIZATION_PATTERN

      static final String AUTHORIZATION_PATTERN
      Pattern of the endpoints that start a sign-in.
      See Also:
    • CALLBACK_PATTERN

      static final String CALLBACK_PATTERN
      Pattern of the endpoints that receive the provider's answer.
      See Also:
    • clientRegistrationRepository

      private final org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository
      Registrations of the configured providers.
    • oidcUserService

      private final FederatedOidcUserService oidcUserService
      Resolves the account of an OpenID Connect sign-in.
    • oauth2UserService

      private final FederatedOAuth2UserService oauth2UserService
      Resolves the account of an OAuth 2.0 sign-in.
    • successHandler

      private final org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler
      Grants the federated factor and resumes the saved request, or completes a link.
    • failureHandler

      private final org.springframework.security.web.authentication.AuthenticationFailureHandler failureHandler
      Sends a refused link back to the identities page, any other failure to the login page.
    • securityContextRepository

      private final org.springframework.security.web.context.SecurityContextRepository securityContextRepository
      Saves the security context of the sign-in.
    • tokenResponseClient

      private final org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient<org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest> tokenResponseClient
      Exchanges the authorization code for tokens.
    • authorizationRequestResolver

      private final org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver authorizationRequestResolver
      Builds the authorization requests.
    • appleEnabled

      private final boolean appleEnabled
      Whether Apple is configured, which posts its answer to the callback.
  • Constructor Details

    • SocialChainCustomizer

      public SocialChainCustomizer()
  • Method Details

    • customize

      public void customize(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      Customizes the login/UI chain.
      Specified by:
      customize in interface LoginChainCustomizer
      Parameters:
      http - security builder of the chain.