Class OttPagesController
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttPagesController
- All Implemented Interfaces:
OneTimeTokenPageApi
Serves the two pages of the one-time token flow, as the contract
apis/auth-server/web-pages/
auth-server-pages-v1.yaml describes them through the generated OneTimeTokenPageApi: the page where the code
is entered (or that says to check the inbox when a magic link was requested) and the page a magic link opens, whose
button posts the token. What the first one shows comes from the pending token of the session (see
PendingOtt), so it is the same page whatever identifier was typed.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringName of the model attribute that holds the channel,emailorsms.(package private) static final StringName of the model attribute that holds the name of the form field of the code.(package private) static final StringValue of the kind attribute of a numeric code.(package private) static final StringName of the template of the page where the code is entered.(package private) static final StringName of the template of the confirmation page.(package private) static final StringName of the model attribute that holds the key of the message of a failed attempt.(package private) static final StringName of the model attribute that holds the path a new token is requested at.(package private) static final StringKey of the message shown when a code is wrong.(package private) static final StringName of the model attribute that holds the kind of token,codeorlink.(package private) static final StringKey of the message shown when the second factor is locked.(package private) static final StringValue of the purpose attribute of a sign-in.static final StringPath of the page where the code is entered, taken from the contract.private final PageRendererRenders the pages.(package private) static final StringName of the model attribute that tells whether this browser has asked for a token.(package private) static final StringName of the model attribute that holds the path the code form posts to.(package private) static final StringName of the model attribute that holds the purpose,loginorsecond-factor.(package private) static final StringName of the header that tells browsers to send no referrer.private final jakarta.servlet.http.HttpServletRequestThe current request, injected as a thread-bound proxy, whose session holds the pending token.(package private) static final StringName of the model attribute that holds the token of the magic link.Fields inherited from interface com.irurueta.authserver.authorization.api.web.pages.v1.generated.api.OneTimeTokenPageApi
PATH_OTT_CODE_PAGE, PATH_OTT_CONFIRM_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanTells whether the previous attempt failed because the second factor is locked, which Spring Security keeps in the session.private static StringLower-cases a name, whatever the platform's locale is.org.springframework.http.ResponseEntity<String> ottCodePage(String error) Renders the page where the code is entered.org.springframework.http.ResponseEntity<String> ottConfirmPage(String token) Renders the page a magic link opens.
-
Field Details
-
OTT_CODE_PATH
Path of the page where the code is entered, taken from the contract.- See Also:
-
CODE_VIEW_NAME
Name of the template of the page where the code is entered.- See Also:
-
CONFIRM_VIEW_NAME
Name of the template of the confirmation page.- See Also:
-
PENDING_ATTRIBUTE
Name of the model attribute that tells whether this browser has asked for a token.- See Also:
-
KIND_ATTRIBUTE
Name of the model attribute that holds the kind of token,codeorlink.- See Also:
-
CHANNEL_ATTRIBUTE
Name of the model attribute that holds the channel,emailorsms.- See Also:
-
PURPOSE_ATTRIBUTE
Name of the model attribute that holds the purpose,loginorsecond-factor.- See Also:
-
POST_PATH_ATTRIBUTE
Name of the model attribute that holds the path the code form posts to.- See Also:
-
CODE_FIELD_ATTRIBUTE
Name of the model attribute that holds the name of the form field of the code.- See Also:
-
GENERATE_PATH_ATTRIBUTE
Name of the model attribute that holds the path a new token is requested at.- See Also:
-
ERROR_MESSAGE_ATTRIBUTE
Name of the model attribute that holds the key of the message of a failed attempt.- See Also:
-
TOKEN_ATTRIBUTE
Name of the model attribute that holds the token of the magic link.- See Also:
-
GENERIC_ERROR
Key of the message shown when a code is wrong.- See Also:
-
LOCKED_ERROR
Key of the message shown when the second factor is locked.- See Also:
-
LOGIN_VALUE
Value of the purpose attribute of a sign-in.- See Also:
-
CODE_VALUE
Value of the kind attribute of a numeric code.- See Also:
-
REFERRER_POLICY
Name of the header that tells browsers to send no referrer.- See Also:
-
pageRenderer
Renders the pages. -
request
private final jakarta.servlet.http.HttpServletRequest requestThe current request, injected as a thread-bound proxy, whose session holds the pending token.
-
-
Constructor Details
-
OttPagesController
public OttPagesController()
-
-
Method Details
-
ottCodePage
Renders the page where the code is entered.- Specified by:
ottCodePagein interfaceOneTimeTokenPageApi- Parameters:
error- present (even if empty) when the previous attempt failed.- Returns:
- the page.
-
ottConfirmPage
Renders the page a magic link opens. It is never cached and a browser sends no referrer from it, because the token is in its address.- Specified by:
ottConfirmPagein interfaceOneTimeTokenPageApi- Parameters:
token- the token of the link, which is only posted back, never checked here.- Returns:
- the confirmation 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:
truewhen the session holds aLockedExceptionas the last failure.
-
lowerCase
Lower-cases a name, whatever the platform's locale is.- Parameters:
name- the name.- Returns:
- the name in lower case.
-