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 Details

    • verifyOneTimeCodeUseCase

      private final VerifyOneTimeCodeUseCase verifyOneTimeCodeUseCase
      Verifies the code.
    • userDetailsService

      private final org.springframework.security.core.userdetails.UserDetailsService userDetailsService
      Loads the account, refusing one that cannot sign in.
    • factorGrantor

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

      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 OttCodeAuthenticationToken.