java.lang.Object
com.irurueta.authserver.authorization.api.web.login.LoginController
All Implemented Interfaces:
LoginPageApi

@Controller public class LoginController extends Object implements LoginPageApi
Serves the login page, as the contract apis/auth-server/web-pages/auth-server-pages-v1.yaml describes it through the generated LoginPageApi, supplying the ordered login method fragments and the outcome of the last attempt to the template.
  • Field Details

    • LOGIN_PATH

      public static final String LOGIN_PATH
      Path of the login page, which also receives the form post. The single source of the path for the security chains and the template, taken from the contract.
      See Also:
    • VIEW_NAME

      static final String VIEW_NAME
      Name of the login template.
      See Also:
    • LOGIN_PATH_ATTRIBUTE

      static final String LOGIN_PATH_ATTRIBUTE
      Name of the model attribute that holds the path the login form posts to.
      See Also:
    • FRAGMENTS_ATTRIBUTE

      static final String FRAGMENTS_ATTRIBUTE
      Name of the model attribute that holds the fragments of the login methods.
      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 sign-in.
      See Also:
    • LOGGED_OUT_ATTRIBUTE

      static final String LOGGED_OUT_ATTRIBUTE
      Name of the model attribute that tells the user has just signed out.
      See Also:
    • fragments

      private final List<LoginMethodFragment> fragments
      Fragments contributed by the authentication methods, sorted by order.
    • errorMessages

      private final LoginErrorMessages errorMessages
      Maps the last authentication exception to a message key.
    • 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

    • LoginController

      public LoginController(List<LoginMethodFragment> methods, LoginErrorMessages errorMessages, PageRenderer pageRenderer, jakarta.servlet.http.HttpServletRequest request)
      Creates the controller.
      Parameters:
      methods - fragments contributed by the authentication methods.
      errorMessages - mapper of the authentication exceptions to message keys.
      pageRenderer - renderer of the page.
      request - the current request.
  • Method Details

    • loginPage

      public org.springframework.http.ResponseEntity<String> loginPage(String error, String logout)
      Renders the login page.
      Specified by:
      loginPage in interface LoginPageApi
      Parameters:
      error - present (even if empty) when the previous attempt failed.
      logout - present (even if empty) when the user has just signed out.
      Returns:
      the login page.
    • lastFailure

      private org.springframework.security.core.AuthenticationException lastFailure()
      Gets the exception of the previous failed attempt, which Spring Security keeps in the session.
      Returns:
      the exception, or null when there is no session or it holds none.