Class MfaAuthorizationManager

java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.MfaAuthorizationManager
All Implemented Interfaces:
org.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>

public class MfaAuthorizationManager extends Object implements org.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>
Decides whether an authentication has presented enough factors for the request being served: when the client or the user requires multi-factor authentication, the factors must satisfy the MfaPolicy; otherwise any authentication does. A refusal names the second factors that are missing, so Spring Security can send the user to the page that collects them.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Registry of the known factors.
    Use case that tells whether a client requires a second factor.
    Use case that tells whether a user's account requires a second factor.
    private final MfaPolicy
    Policy that decides which factors are enough and when a second factor is required.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authorization.AuthorizationResult
    authorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context)
    Decides for a request, taking the client from its client_id parameter.
    boolean
    Tells whether a client makes multi-factor authentication mandatory, asking the application (one lookup of the client, only for a request that names one).
    org.springframework.security.authorization.AuthorizationResult
    evaluate(org.springframework.security.core.Authentication authentication, boolean clientRequires)
    Decides for an authentication.
    static boolean
    isUser(org.springframework.security.core.Authentication authentication)
    Tells whether an authentication is a signed-in user (not missing, unauthenticated or anonymous).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.security.authorization.AuthorizationManager

    verify
  • Field Details

    • mfaPolicy

      private final MfaPolicy mfaPolicy
      Policy that decides which factors are enough and when a second factor is required.
    • factorRegistry

      private final AuthenticationFactorRegistry factorRegistry
      Registry of the known factors.
    • isUserMfaRequiredUseCase

      private final IsUserMfaRequiredUseCase isUserMfaRequiredUseCase
      Use case that tells whether a user's account requires a second factor.
    • isClientMfaRequiredUseCase

      private final IsClientMfaRequiredUseCase isClientMfaRequiredUseCase
      Use case that tells whether a client requires a second factor.
  • Constructor Details

    • MfaAuthorizationManager

      public MfaAuthorizationManager()
  • Method Details

    • authorize

      public org.springframework.security.authorization.AuthorizationResult authorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context)
      Decides for a request, taking the client from its client_id parameter.
      Specified by:
      authorize in interface org.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>
      Parameters:
      authentication - supplier of the current authentication.
      context - the request being served.
      Returns:
      the decision: granted, refused, or refused naming the missing second factors.
    • clientRequiresMfa

      public boolean clientRequiresMfa(String clientId)
      Tells whether a client makes multi-factor authentication mandatory, asking the application (one lookup of the client, only for a request that names one).
      Parameters:
      clientId - public identifier of the client, may be null when the request names none.
      Returns:
      true when the client is registered and requires a second factor.
    • evaluate

      public org.springframework.security.authorization.AuthorizationResult evaluate(org.springframework.security.core.Authentication authentication, boolean clientRequires)
      Decides for an authentication.
      Parameters:
      authentication - the authenticated user.
      clientRequires - whether the client being served requires multi-factor authentication.
      Returns:
      granted when MFA is not required or the factors satisfy the policy; otherwise refused, naming the registered second factors as missing (or a plain refusal when none is registered).
    • isUser

      public static boolean isUser(org.springframework.security.core.Authentication authentication)
      Tells whether an authentication is a signed-in user (not missing, unauthenticated or anonymous).
      Parameters:
      authentication - the authentication, may be null.
      Returns:
      true for a signed-in user.