@Override
    public boolean shouldMultifactorAuthenticationProviderExecuteInternal(final Authentication authentication,
                                                                          final RegisteredService registeredService,
                                                                          final MultifactorAuthenticationProvider provider,
                                                                          final HttpServletRequest request) {

        if (registeredService != null) {
            val mfaPolicy = registeredService.getMultifactorAuthenticationPolicy();
            val bypassEnabled = mfaPolicy != null
                                && StringUtils.isNotBlank(mfaPolicy.getBypassPrincipalAttributeName())
                                && StringUtils.isNotBlank(mfaPolicy.getBypassPrincipalAttributeValue());

            if (bypassEnabled) {
                val principal = resolvePrincipal(authentication.getPrincipal());

                val matchingAttributes = locateMatchingAttributeName(principal.getAttributes(), mfaPolicy.getBypassPrincipalAttributeName());
                if (matchingAttributes.isEmpty()) {
                    LOGGER.debug("No matching principal attribute name from [{}] can be found for [{}]",
                        principal.getAttributes().keySet(), mfaPolicy.getBypassPrincipalAttributeName());
                    return !mfaPolicy.isBypassIfMissingPrincipalAttribute();
                }

                val bypass = locateMatchingAttributeValue(mfaPolicy.getBypassPrincipalAttributeName(),
                    org.springframework.util.StringUtils.commaDelimitedListToSet(mfaPolicy.getBypassPrincipalAttributeValue()),
                    principal.getAttributes(), true);
                if (bypass) {
                    LOGGER.debug("Bypass rules for principal [{}] indicate the request may be ignored", principal.getId());
                    return false;
                }
            }
        }
        return true;
    }
Multifactor Bypass based on Principal Attributes.

@author Travis Schmidt
@since 6.0
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/bypass/RegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator.java