Class SecondFactorController

java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.SecondFactorController
All Implemented Interfaces:
SecondFactorPageApi

@Controller public class SecondFactorController extends Object implements SecondFactorPageApi
Serves the second-factor page, as the contract apis/auth-server/web-pages/auth-server-pages-v1.yaml describes it through the generated SecondFactorPageApi, supplying the ordered fragments of the second factors, the model attributes each of them contributes for the signed-in user and the outcome of the last attempt to the template.
  • Field Details

    • SECOND_FACTOR_PATH

      public static final String SECOND_FACTOR_PATH
      Path of the second-factor page, taken from the contract.
      See Also:
    • GENERIC_ERROR

      public static final String GENERIC_ERROR
      Key of the message shown when a code is wrong.
      See Also:
    • LOCKED_ERROR

      public static final String LOCKED_ERROR
      Key of the message shown when the second factor is locked.
      See Also:
    • VIEW_NAME

      static final String VIEW_NAME
      Name of the second-factor template.
      See Also:
    • FRAGMENTS_ATTRIBUTE

      static final String FRAGMENTS_ATTRIBUTE
      Name of the model attribute that holds the fragments of the second factors.
      See Also:
    • ERROR_MESSAGE_ATTRIBUTE

      static final String ERROR_MESSAGE_ATTRIBUTE
      Name of the model attribute that holds the key of the message of a failed attempt.
      See Also:
    • fragments

      private final List<SecondFactorFragment> fragments
      Fragments contributed by the second factors, sorted by order.
    • pageRenderer

      private final PageRenderer pageRenderer
      Renders the page.
    • request

      private final jakarta.servlet.http.HttpServletRequest request
      The current request, injected as a thread-bound proxy, whose session holds the last failure.
  • Constructor Details

    • SecondFactorController

      public SecondFactorController(List<SecondFactorFragment> factors, PageRenderer pageRenderer, jakarta.servlet.http.HttpServletRequest request)
      Creates the controller.
      Parameters:
      factors - fragments contributed by the second factors.
      pageRenderer - renderer of the page.
      request - the current request.
  • Method Details

    • secondFactorPage

      public org.springframework.http.ResponseEntity<String> secondFactorPage(String error)
      Renders the second-factor page.
      Specified by:
      secondFactorPage in interface SecondFactorPageApi
      Parameters:
      error - present (even if empty) when the previous attempt failed.
      Returns:
      the second-factor page.
    • lastFailureWasLockout

      private boolean lastFailureWasLockout()
      Tells whether the previous attempt failed because the second factor is locked, which Spring Security keeps in the session.
      Returns:
      true when the session holds a LockedException as the last failure.