Class DeviceVerificationErrorHandler
java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.DeviceVerificationErrorHandler
- All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationFailureHandler
public class DeviceVerificationErrorHandler
extends Object
implements org.springframework.security.web.authentication.AuthenticationFailureHandler
Error handler of the device verification endpoint. A user who owes a second factor goes where the authorization
endpoint sends them (the
secondFactorHandler); too many attempts are answered 429 with a
Retry-After header; any other failure (an unknown, expired or already used code, a denied consent) sends the
browser back to the verification page with ?error, which says nothing about the reason, so a code cannot be
told apart from a wrong one. Installing a handler replaces the framework's, which only answers 400.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringName of the parameter that tells the verification page that the previous attempt failed.private final org.springframework.security.web.RedirectStrategyStrategy that redirects, honouring the context path.private final org.springframework.security.web.authentication.AuthenticationFailureHandlerHandler of the failures that send the user to the second-factor page or to a new sign-in.private final StringPath of the verification page. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception) Handles a failed verification request.private static longRounds the wait up to whole seconds, at least one.
-
Field Details
-
ERROR_PARAMETER
Name of the parameter that tells the verification page that the previous attempt failed.- See Also:
-
redirectStrategy
private final org.springframework.security.web.RedirectStrategy redirectStrategyStrategy that redirects, honouring the context path. -
secondFactorHandler
private final org.springframework.security.web.authentication.AuthenticationFailureHandler secondFactorHandlerHandler of the failures that send the user to the second-factor page or to a new sign-in. -
verificationPath
Path of the verification page.
-
-
Constructor Details
-
DeviceVerificationErrorHandler
public DeviceVerificationErrorHandler()
-
-
Method Details
-
onAuthenticationFailure
public void onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception) throws IOException, jakarta.servlet.ServletException Handles a failed verification request.- Specified by:
onAuthenticationFailurein interfaceorg.springframework.security.web.authentication.AuthenticationFailureHandler- Parameters:
request- the request.response- the response.exception- why the request failed.- Throws:
IOException- if the response cannot be written.jakarta.servlet.ServletException- if the second-factor handler fails.
-
retryAfterSeconds
Rounds the wait up to whole seconds, at least one.- Parameters:
exception- the failure.- Returns:
- the seconds to wait.
-