Class SecondFactorRequiredEntryPoint

java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.SecondFactorRequiredEntryPoint
All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint

public class SecondFactorRequiredEntryPoint extends Object implements org.springframework.security.web.AuthenticationEntryPoint
Sends a user who has presented a primary factor but not yet the second one to the second-factor page, after saving the request being served (typically /oauth2/authorize?...) so the sign-in resumes where it left off once the second factor is verified. It also records in the session whether the request is a step-up (SecondFactorRequiredException.isStepUp()), which TrustedDeviceFilter reads so that a trusted device does not resume a request it cannot satisfy (that would redirect back here again).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.springframework.security.web.RedirectStrategy
    Strategy that redirects, honouring the context path.
    private final org.springframework.security.web.savedrequest.RequestCache
    Cache that keeps the request to resume after the second factor, shared with the form login.
    static final String
    Path of the second-factor page.
    static final String
    Name of the session attribute present while the pending request is a step-up that needs a real factor.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException)
    Saves the request, remembers whether it is a step-up and redirects to the second-factor page.
    static boolean
    isStepUpPending(jakarta.servlet.http.HttpServletRequest request)
    Tells whether the request the session is waiting to resume is a step-up that needs a real second factor.

    Methods inherited from class java.lang.Object

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

    • SECOND_FACTOR_PATH

      public static final String SECOND_FACTOR_PATH
      Path of the second-factor page.
      See Also:
    • STEP_UP_ATTRIBUTE

      public static final String STEP_UP_ATTRIBUTE
      Name of the session attribute present while the pending request is a step-up that needs a real factor.
    • redirectStrategy

      private final org.springframework.security.web.RedirectStrategy redirectStrategy
      Strategy that redirects, honouring the context path.
    • requestCache

      private final org.springframework.security.web.savedrequest.RequestCache requestCache
      Cache that keeps the request to resume after the second factor, shared with the form login.
  • Constructor Details

    • SecondFactorRequiredEntryPoint

      public SecondFactorRequiredEntryPoint()
  • Method Details

    • isStepUpPending

      public static boolean isStepUpPending(jakarta.servlet.http.HttpServletRequest request)
      Tells whether the request the session is waiting to resume is a step-up that needs a real second factor.
      Parameters:
      request - a request of the session.
      Returns:
      true when the last redirect to the second-factor page was for a step-up.
    • commence

      public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) throws IOException
      Saves the request, remembers whether it is a step-up and redirects to the second-factor page.
      Specified by:
      commence in interface org.springframework.security.web.AuthenticationEntryPoint
      Parameters:
      request - the request that needs a second factor.
      response - the response to redirect.
      authException - why the request was refused.
      Throws:
      IOException - if the redirect cannot be sent.