Class OttGenerationSuccessHandler
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttGenerationSuccessHandler
- All Implemented Interfaces:
org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler
public class OttGenerationSuccessHandler
extends Object
implements org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler
Delivers the token Spring's filter just generated, and answers every request the same way. The token the stock
service stored is the one of a magic link; for a numeric code it is discarded, because a code cannot use that store
(it is keyed by the token value alone, and a six-digit value collides across users), and
RequestOneTimeCodeUseCase stores the code in its own table, bound to a new binding id kept in the session.
Nothing is sent, and nothing differs for the caller, when the identifier is unknown, disabled or has no verified
e-mail address or phone: the browser is always redirected to the page that says to check the inbox, so the response
does not tell whether the account exists. The use cases only request the delivery, which happens after their
transaction commits and off the request thread, so neither a slow mail server or SMS gateway nor a delivery failure
shows in the response.
A token asked for as a second factor is delivered only through a channel OttSecondFactorChannels allows
for the signed-in user (never the channel that signed the user in, and e-mail only to a user without another
confirmed second factor), and a second-factor link only for a user name that fits next to the marker of
LinkTokenUsername. Any other request is answered the same, but its token is discarded and nothing is sent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OttLinkFactoryBuilds the magic link.private final org.springframework.security.authentication.ott.OneTimeTokenServiceStore of the link tokens, which the code requests discard their unused token from.private final org.springframework.security.web.RedirectStrategyRedirects to the page that says to check the inbox.private final RequestMagicLinkUseCaseRequests the delivery of a magic link.private final RequestOneTimeCodeUseCaseStarts the numeric code of a channel.private final OttSecondFactorChannelsDecides which channels may be the second factor of the signed-in user. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.authentication.ott.OneTimeToken token) Delivers the token and redirects to the page that says to check the inbox.private booleanisDeliverable(OttGenerationParameters parameters, org.springframework.security.core.Authentication current) Tells whether a token may be delivered: always for a sign-in; for a second factor only through a channel the signed-in user may use, and a link only when the user name fits the token store with its marker.
-
Field Details
-
requestOneTimeCodeUseCase
Starts the numeric code of a channel. -
requestMagicLinkUseCase
Requests the delivery of a magic link. -
oneTimeTokenService
private final org.springframework.security.authentication.ott.OneTimeTokenService oneTimeTokenServiceStore of the link tokens, which the code requests discard their unused token from. -
linkFactory
Builds the magic link. -
secondFactorChannels
Decides which channels may be the second factor of the signed-in user. -
redirectStrategy
private final org.springframework.security.web.RedirectStrategy redirectStrategyRedirects to the page that says to check the inbox.
-
-
Constructor Details
-
OttGenerationSuccessHandler
public OttGenerationSuccessHandler()
-
-
Method Details
-
handle
public void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.authentication.ott.OneTimeToken token) throws IOException Delivers the token and redirects to the page that says to check the inbox.- Specified by:
handlein interfaceorg.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler- Parameters:
request- the request.response- the response.token- the token Spring's filter generated.- Throws:
IOException- if the redirect cannot be sent.
-
isDeliverable
private boolean isDeliverable(OttGenerationParameters parameters, org.springframework.security.core.Authentication current) Tells whether a token may be delivered: always for a sign-in; for a second factor only through a channel the signed-in user may use, and a link only when the user name fits the token store with its marker.- Parameters:
parameters- what the request asks for.current- the authentication of the request.- Returns:
truewhen the token may be delivered.
-