Class OttSecondFactorAuthenticationProvider
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttSecondFactorAuthenticationProvider
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public class OttSecondFactorAuthenticationProvider
extends Object
implements org.springframework.security.authentication.AuthenticationProvider
Verifies a numeric one-time code, delivered by e-mail or SMS, as the second factor of the signed-in user through
VerifyOneTimeCodeUseCase, which counts the failures against the second-factor lockout, locks after too many,
clears the counter on success and records the security events: a locked second factor is rejected even for a
correct code. Only the channels OttSecondFactorChannels allows are accepted, and that is decided before the
code is compared: a code of another channel (the one that signed the user in, or e-mail for a user with another
confirmed second factor) is a failure counted against the lockout, never a success. A correct code answers with the
authentication the user already holds plus the second-factor authority of the channel.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FactorGrantorAdds the factor authority to an authentication.private final OttSecondFactorChannelsDecides which channels may be the second factor of the user.private final VerifyOneTimeCodeUseCaseVerifies the code. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.Authenticationauthenticate(org.springframework.security.core.Authentication authentication) Verifies the code.booleanTells which requests this provider verifies.
-
Field Details
-
verifyOneTimeCodeUseCase
Verifies the code. -
factorGrantor
Adds the factor authority to an authentication. -
secondFactorChannels
Decides which channels may be the second factor of the user.
-
-
Constructor Details
-
OttSecondFactorAuthenticationProvider
public OttSecondFactorAuthenticationProvider()
-
-
Method Details
-
authenticate
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationException Verifies the code.- Specified by:
authenticatein interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- theOttSecondFactorTokento verify.- Returns:
- the authentication the user already holds with the second factor of the channel added.
- Throws:
org.springframework.security.core.AuthenticationException- if the code is wrong, the second factor is locked or the channel of the code is not allowed for the user.
-
supports
Tells which requests this provider verifies.- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- the type of the request.- Returns:
truefor anOttSecondFactorToken.
-