Class MfaProtocolChainCustomizer

java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.MfaProtocolChainCustomizer
All Implemented Interfaces:
ProtocolChainCustomizer

public class MfaProtocolChainCustomizer extends Object implements ProtocolChainCustomizer
Applies the multi-factor policy to /oauth2/authorize: a user whose client or account requires a second factor and has not presented one is sent to the second-factor page, with the authorize request saved, before any code is issued. The framework's own request validation still runs first.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Manager that applies the policy.
    private final org.springframework.security.web.authentication.AuthenticationFailureHandler
    Handler of the endpoint's errors, which sends the user to the second-factor page when needed.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    customize(org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer server)
    Customizes the authorization endpoint.
    private void
    requireSecondFactor(org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationContext context)
    Refuses the request when the user still owes a second factor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • authorizationManager

      private final MfaAuthorizationManager authorizationManager
      Manager that applies the policy.
    • errorResponseHandler

      private final org.springframework.security.web.authentication.AuthenticationFailureHandler errorResponseHandler
      Handler of the endpoint's errors, which sends the user to the second-factor page when needed.
  • Constructor Details

    • MfaProtocolChainCustomizer

      public MfaProtocolChainCustomizer()
  • Method Details

    • customize

      public void customize(org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer server)
      Customizes the authorization endpoint.
      Specified by:
      customize in interface ProtocolChainCustomizer
      Parameters:
      server - configurer of the authorization server.
    • requireSecondFactor

      private void requireSecondFactor(org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationContext context)
      Refuses the request when the user still owes a second factor.
      Parameters:
      context - the authorization request being validated.
      Throws:
      SecondFactorRequiredException - if the policy is not satisfied.