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
FieldsModifier and TypeFieldDescriptionprivate final AuthenticationFactorRegistryRegistry of the known factors.private final IsClientMfaRequiredUseCaseUse case that tells whether a client requires a second factor.private final IsUserMfaRequiredUseCaseUse case that tells whether a user's account requires a second factor.private final MfaPolicyPolicy that decides which factors are enough and when a second factor is required. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authorization.AuthorizationResultauthorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context) Decides for a request, taking the client from itsclient_idparameter.booleanclientRequiresMfa(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).org.springframework.security.authorization.AuthorizationResultevaluate(org.springframework.security.core.Authentication authentication, boolean clientRequires) Decides for an authentication.static booleanisUser(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, waitMethods inherited from interface org.springframework.security.authorization.AuthorizationManager
verify
-
Field Details
-
mfaPolicy
Policy that decides which factors are enough and when a second factor is required. -
factorRegistry
Registry of the known factors. -
isUserMfaRequiredUseCase
Use case that tells whether a user's account requires a second factor. -
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 itsclient_idparameter.- Specified by:
authorizein interfaceorg.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
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 benullwhen the request names none.- Returns:
truewhen 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 benull.- Returns:
truefor a signed-in user.
-