Class X509ChainCustomizer

java.lang.Object
com.irurueta.authserver.authorization.api.web.x509.X509ChainCustomizer
All Implemented Interfaces:
LoginChainCustomizer

public class X509ChainCustomizer extends Object implements LoginChainCustomizer
Adds the sign-in with a client certificate to the login/UI chain through http.x509(...). The filter only looks at POST /login/x509, the form of X509LoginMethodFragment on the login page, which carries the CSRF token like every other form of the chain; the CSRF filter runs before the X.509 one, so a cross-site page can never make a browser sign in with its certificate. The form posts to the TLS port that requests a certificate (or to the proxy that forwards one); every other request of the chain is untouched, and GET /login/x509 is not a sign-in at all (it is not opened, so it ends with the chain's catch-all rule). A certificate that is bound to an account signs it in and resumes the interrupted request, anything else goes back to the login page. The path is open to everybody, because it is where the certificate is checked. When a proxy may forward the certificate, ForwardedCertificateFilter runs first. Once the chain is configured, the success handler gets the chain's session authentication strategy, the one the form login uses.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    Hands the session authentication strategy of the chain to the success handler.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Where a failed sign-in goes.
    private final X509LoginFilter
    The filter that authenticates the certificate.
    The filter that reads a forwarded certificate, or null when the transport is off.
    static final String
    Path of the sign-in with a certificate, which is served by the security filter.
    static final int
    Order of the customizer: after the social login one.
    private final org.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor
    Takes the principal of the certificate.
    Completes the sign-in.
    private final org.springframework.security.core.userdetails.AuthenticationUserDetailsService<org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken>
    Loads the account of the certificate.
  • 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.
    private void
    prepare(X509LoginFilter loginFilter, org.springframework.security.web.util.matcher.RequestMatcher loginRequest, org.springframework.security.config.annotation.web.builders.HttpSecurity http)
    Sets up the filter, which the x509 configurer takes as it is.

    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 social login one.
      See Also:
    • LOGIN_PATH

      public static final String LOGIN_PATH
      Path of the sign-in with a certificate, which is served by the security filter.
      See Also:
    • FAILURE_URL

      static final String FAILURE_URL
      Where a failed sign-in goes.
      See Also:
    • filter

      private final X509LoginFilter filter
      The filter that authenticates the certificate.
    • principalExtractor

      private final org.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor principalExtractor
      Takes the principal of the certificate.
    • userDetailsService

      private final org.springframework.security.core.userdetails.AuthenticationUserDetailsService<org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken> userDetailsService
      Loads the account of the certificate.
    • forwardedFilter

      private final ForwardedCertificateFilter forwardedFilter
      The filter that reads a forwarded certificate, or null when the transport is off.
    • successHandler

      private final X509AuthenticationSuccessHandler successHandler
      Completes the sign-in.
  • Constructor Details

    • X509ChainCustomizer

      public X509ChainCustomizer()
  • 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.
    • prepare

      private void prepare(X509LoginFilter loginFilter, org.springframework.security.web.util.matcher.RequestMatcher loginRequest, org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      Sets up the filter, which the x509 configurer takes as it is.
      Parameters:
      loginFilter - the filter.
      loginRequest - matcher of the sign-in requests.
      http - security builder of the chain, whose authentication manager the filter uses once built.