Class OttCodeAuthenticationProvider
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttCodeAuthenticationProvider
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public class OttCodeAuthenticationProvider
extends Object
implements org.springframework.security.authentication.AuthenticationProvider
Signs a user in with a numeric one-time code, delivered by e-mail or SMS, through
VerifyOneTimeCodeUseCase.
The code only counts in the session whose binding id it was stored with, and is consumed by the first correct
submission. The account is loaded through the user service of the chain, which refuses a disabled, locked or expired
account. A correct code answers with the user's authentication plus the sign-in authority of the channel the code
was delivered through (FACTOR_OTT for e-mail, FACTOR_OTT_SMS for SMS), which Spring Security's
authentication filter merges with the factors the session already holds.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FactorGrantorAdds the factor authority to an authentication.private final org.springframework.security.core.userdetails.UserDetailsServiceLoads the account, refusing one that cannot sign in.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. -
userDetailsService
private final org.springframework.security.core.userdetails.UserDetailsService userDetailsServiceLoads the account, refusing one that cannot sign in. -
factorGrantor
Adds the factor authority to an authentication.
-
-
Constructor Details
-
OttCodeAuthenticationProvider
public OttCodeAuthenticationProvider()
-
-
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- theOttCodeAuthenticationTokento verify.- Returns:
- the authentication of the user, with the factor of the channel.
- Throws:
org.springframework.security.core.AuthenticationException- if the code is not valid or the account cannot sign in.
-
supports
Tells which requests this provider verifies.- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- the type of the request.- Returns:
truefor anOttCodeAuthenticationToken.
-