Class X509LoginMethodFragment

java.lang.Object
com.irurueta.authserver.authorization.api.web.x509.X509LoginMethodFragment
All Implemented Interfaces:
LoginMethodFragment

public class X509LoginMethodFragment extends Object implements LoginMethodFragment
Contributes the sign-in with a client certificate to the login page: a form with one button that posts, with the CSRF token, to POST /login/x509. The template reads action() through this bean, because where the form posts depends on the transport:
  • with a proxy that forwards the certificate, the proxy fronts the whole application, so the form posts to the relative path, on the origin of the page;
  • with only the dedicated TLS port, the certificate is requested by that port alone, so a page served on any other port posts to the same host on that port over https; a page already served on that port posts to the relative path.
The session cookie and the CSRF token stay valid on the other port (cookies belong to a host, not to a port), but a browser only sends a cookie with a SameSite restriction on a post between pages of the same site, and it counts http and https as different sites: the main port must be served over https too, or the login page must be opened on the TLS port. The bean only exists while the sign-in with a certificate is enabled.
  • Field Details

    • ORDER

      public static final int ORDER
      Position of the certificate sign-in in the login page: after the social one, before the one-time tokens.
      See Also:
    • HTTPS

      private static final String HTTPS
      Scheme of the dedicated TLS port.
      See Also:
    • properties

      private final X509Properties properties
      Settings, which tell the transports and the TLS port.
  • Constructor Details

    • X509LoginMethodFragment

      public X509LoginMethodFragment(X509Properties properties)
      Creates the fragment.
      Parameters:
      properties - settings of the sign-in with a certificate.
  • Method Details

    • templateName

      public String templateName()
      Gets the template that holds the fragment.
      Specified by:
      templateName in interface LoginMethodFragment
      Returns:
      login-x509.
    • fragmentName

      public String fragmentName()
      Gets the fragment of the template.
      Specified by:
      fragmentName in interface LoginMethodFragment
      Returns:
      login.
    • order

      public int order()
      Gets the position of the fragment.
      Specified by:
      order in interface LoginMethodFragment
      Returns:
      ORDER.
    • action

      public String action()
      Gets the address the form of the page being rendered posts to.
      Returns:
      the address of the sign-in request for the current request; the relative path when there is none.
    • action

      public String action(jakarta.servlet.http.HttpServletRequest request)
      Gets the address the form of a page posts to.
      Parameters:
      request - the request of the page.
      Returns:
      the relative path (with the context path) when a proxy forwards the certificate, when there is no TLS port or when the page is served on it; otherwise the absolute address on the TLS port of the same host.