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 Details

    • verifyOneTimeCodeUseCase

      private final VerifyOneTimeCodeUseCase verifyOneTimeCodeUseCase
      Verifies the code.
    • factorGrantor

      private final FactorGrantor factorGrantor
      Adds the factor authority to an authentication.
    • secondFactorChannels

      private final OttSecondFactorChannels 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:
      authenticate in interface org.springframework.security.authentication.AuthenticationProvider
      Parameters:
      authentication - the OttSecondFactorToken to 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

      public boolean supports(Class<?> authentication)
      Tells which requests this provider verifies.
      Specified by:
      supports in interface org.springframework.security.authentication.AuthenticationProvider
      Parameters:
      authentication - the type of the request.
      Returns:
      true for an OttSecondFactorToken.