Class TotpAuthenticationProvider
java.lang.Object
com.irurueta.authserver.authorization.api.web.totp.TotpAuthenticationProvider
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public class TotpAuthenticationProvider
extends Object
implements org.springframework.security.authentication.AuthenticationProvider
Verifies a TOTP code or a recovery code for the signed-in user, or the first code of an authenticator app being
enrolled during the sign-in, which confirms it, through the
TotpCodeVerifier. The use cases count the
failures, lock the second factor after too many and clear the counter on success; a locked second factor is
rejected even for a correct code. A correct code
answers with the authentication the user already holds plus the TOTP factor authority; an enrolment also hands the
new recovery codes back through the request token.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FactorGrantorAdds the factor authority to an authentication.private final TotpCodeVerifierSends the code to the use case of its kind.private final SecondFactorUserResolverResolves the identifier of the account of the signed-in user. -
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
-
totpCodeVerifier
Sends the code to the use case of its kind. -
userResolver
Resolves the identifier of the account of the signed-in user. -
factorGrantor
Adds the factor authority to an authentication.
-
-
Constructor Details
-
TotpAuthenticationProvider
public TotpAuthenticationProvider()
-
-
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- theTotpAuthenticationTokento verify.- Returns:
- the authentication the user already holds with the TOTP factor added.
- Throws:
org.springframework.security.core.AuthenticationException- if the code is wrong, the second factor is locked or the account is unknown.
-
supports
Tells which requests this provider verifies.- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- the type of the request.- Returns:
truefor aTotpAuthenticationToken.
-