Class OttSecondFactorChannels

java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttSecondFactorChannels

@Component public class OttSecondFactorChannels extends Object
Decides through which channels a one-time code or link may be the second factor of a signed-in user. The same rule decides what the second-factor page offers, whether a requested token is delivered at all and whether a presented one is accepted, so a channel that is not offered can neither be asked for nor used by posting the forms by hand:
  • never the channel that signed the user in (the same mailbox or phone would be proved twice);
  • SMS only to a user with a verified phone;
  • e-mail only to a user without any other confirmed second factor (authenticator app, passkey, verified phone). The password is reset by e-mail too, so a mailbox is not independent from the password: whoever controls it could otherwise skip the stronger factor the user enrolled. For a user whose multi-factor authentication was forced by an administrator before any factor was enrolled, the e-mail is then the only second factor available.
  • Field Details

    • primaryFactorSession

      private final PrimaryFactorSession primaryFactorSession
      Rules about the session a second factor is presented in.
    • userResolver

      private final SecondFactorUserResolver userResolver
      Resolves the identifier of the account of the signed-in user.
    • hasConfirmedSecondFactorUseCase

      private final HasConfirmedSecondFactorUseCase hasConfirmedSecondFactorUseCase
      Tells whether the user has a confirmed second factor of any kind.
    • hasVerifiedPhoneUseCase

      private final HasVerifiedPhoneUseCase hasVerifiedPhoneUseCase
      Tells whether the user has a verified phone.
  • Constructor Details

    • OttSecondFactorChannels

      public OttSecondFactorChannels()
  • Method Details

    • allowed

      public Set<OttChannel> allowed(org.springframework.security.core.Authentication authentication)
      Gets the channels a signed-in user may use as the second factor.
      Parameters:
      authentication - the authentication of the session, which holds a primary factor.
      Returns:
      the channels; empty when none may be used.
    • isAllowed

      public boolean isAllowed(org.springframework.security.core.Authentication authentication, OttChannel channel)
      Tells whether a signed-in user may use a channel as the second factor.
      Parameters:
      authentication - the authentication of the session, which holds a primary factor.
      channel - the channel.
      Returns:
      true when the channel is one of allowed(Authentication).