Search in sources :

Example 1 with DefaultChainingMultifactorAuthenticationBypassProvider

use of org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider in project cas by apereo.

the class AccepttoMultifactorAuthenticationMultifactorProviderBypassConfiguration method casAccepttoMultifactorBypassEvaluator.

@ConditionalOnMissingBean(name = "casAccepttoMultifactorBypassEvaluator")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorBypassEvaluator(final CasConfigurationProperties casProperties, @Qualifier("casAccepttoMultifactorPrincipalMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorPrincipalMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorRegisteredServiceMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorRegisteredServiceMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator, @Qualifier("casAccepttoMultifactorAuthenticationMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorAuthenticationMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorCredentialMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorCredentialMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorHttpRequestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorHttpRequestMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorGroovyMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorGroovyMultifactorAuthenticationProviderBypass, @Qualifier("casAccepttoMultifactorRestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator casAccepttoMultifactorRestMultifactorAuthenticationProviderBypass) {
    val bypass = new DefaultChainingMultifactorAuthenticationBypassProvider();
    val props = casProperties.getAuthn().getMfa().getAcceptto().getBypass();
    if (StringUtils.isNotBlank(props.getPrincipalAttributeName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorPrincipalMultifactorAuthenticationProviderBypass);
    }
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorRegisteredServiceMultifactorAuthenticationProviderBypass);
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator);
    if (StringUtils.isNotBlank(props.getAuthenticationAttributeName()) || StringUtils.isNotBlank(props.getAuthenticationHandlerName()) || StringUtils.isNotBlank(props.getAuthenticationMethodName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorAuthenticationMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getCredentialClassType())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorCredentialMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getHttpRequestHeaders()) || StringUtils.isNotBlank(props.getHttpRequestRemoteAddress())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorHttpRequestMultifactorAuthenticationProviderBypass);
    }
    if (props.getGroovy().getLocation() != null) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorGroovyMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getRest().getUrl())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(casAccepttoMultifactorRestMultifactorAuthenticationProviderBypass);
    }
    return bypass;
}
Also used : lombok.val(lombok.val) DefaultChainingMultifactorAuthenticationBypassProvider(org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DefaultChainingMultifactorAuthenticationBypassProvider

use of org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider in project cas by apereo.

the class U2FAuthenticationMultifactorProviderBypassConfiguration method u2fBypassEvaluator.

@ConditionalOnMissingBean(name = "u2fBypassEvaluator")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MultifactorAuthenticationProviderBypassEvaluator u2fBypassEvaluator(final CasConfigurationProperties casProperties, @Qualifier("u2fPrincipalMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fPrincipalMultifactorAuthenticationProviderBypass, @Qualifier("u2fRegisteredServiceMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fRegisteredServiceMultifactorAuthenticationProviderBypass, @Qualifier("u2fRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator") final MultifactorAuthenticationProviderBypassEvaluator u2fRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator, @Qualifier("u2fAuthenticationMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fAuthenticationMultifactorAuthenticationProviderBypass, @Qualifier("u2fCredentialMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fCredentialMultifactorAuthenticationProviderBypass, @Qualifier("u2fHttpRequestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fHttpRequestMultifactorAuthenticationProviderBypass, @Qualifier("u2fGroovyMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fGroovyMultifactorAuthenticationProviderBypass, @Qualifier("u2fRestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator u2fRestMultifactorAuthenticationProviderBypass) {
    val bypass = new DefaultChainingMultifactorAuthenticationBypassProvider();
    val props = casProperties.getAuthn().getMfa().getU2f().getBypass();
    if (StringUtils.isNotBlank(props.getPrincipalAttributeName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fPrincipalMultifactorAuthenticationProviderBypass);
    }
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fRegisteredServiceMultifactorAuthenticationProviderBypass);
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator);
    if (StringUtils.isNotBlank(props.getAuthenticationAttributeName()) || StringUtils.isNotBlank(props.getAuthenticationHandlerName()) || StringUtils.isNotBlank(props.getAuthenticationMethodName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fAuthenticationMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getCredentialClassType())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fCredentialMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getHttpRequestHeaders()) || StringUtils.isNotBlank(props.getHttpRequestRemoteAddress())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fHttpRequestMultifactorAuthenticationProviderBypass);
    }
    if (props.getGroovy().getLocation() != null) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fGroovyMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getRest().getUrl())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(u2fRestMultifactorAuthenticationProviderBypass);
    }
    return bypass;
}
Also used : lombok.val(lombok.val) DefaultChainingMultifactorAuthenticationBypassProvider(org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with DefaultChainingMultifactorAuthenticationBypassProvider

use of org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider in project cas by apereo.

the class YubiKeyAuthenticationMultifactorProviderBypassConfiguration method yubikeyBypassEvaluator.

@ConditionalOnMissingBean(name = "yubikeyBypassEvaluator")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MultifactorAuthenticationProviderBypassEvaluator yubikeyBypassEvaluator(final CasConfigurationProperties casProperties, @Qualifier("yubikeyPrincipalMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyPrincipalMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyRegisteredServiceMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyRegisteredServiceMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator") final MultifactorAuthenticationProviderBypassEvaluator yubikeyRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator, @Qualifier("yubikeyAuthenticationMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyAuthenticationMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyCredentialMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyCredentialMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyHttpRequestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyHttpRequestMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyGroovyMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyGroovyMultifactorAuthenticationProviderBypass, @Qualifier("yubikeyRestMultifactorAuthenticationProviderBypass") final MultifactorAuthenticationProviderBypassEvaluator yubikeyRestMultifactorAuthenticationProviderBypass) {
    val bypass = new DefaultChainingMultifactorAuthenticationBypassProvider();
    val props = casProperties.getAuthn().getMfa().getYubikey().getBypass();
    if (StringUtils.isNotBlank(props.getPrincipalAttributeName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyPrincipalMultifactorAuthenticationProviderBypass);
    }
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyRegisteredServiceMultifactorAuthenticationProviderBypass);
    bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyRegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator);
    if (StringUtils.isNotBlank(props.getAuthenticationAttributeName()) || StringUtils.isNotBlank(props.getAuthenticationHandlerName()) || StringUtils.isNotBlank(props.getAuthenticationMethodName())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyAuthenticationMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getCredentialClassType())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyCredentialMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getHttpRequestHeaders()) || StringUtils.isNotBlank(props.getHttpRequestRemoteAddress())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyHttpRequestMultifactorAuthenticationProviderBypass);
    }
    if (props.getGroovy().getLocation() != null) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyGroovyMultifactorAuthenticationProviderBypass);
    }
    if (StringUtils.isNotBlank(props.getRest().getUrl())) {
        bypass.addMultifactorAuthenticationProviderBypassEvaluator(yubikeyRestMultifactorAuthenticationProviderBypass);
    }
    return bypass;
}
Also used : lombok.val(lombok.val) DefaultChainingMultifactorAuthenticationBypassProvider(org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with DefaultChainingMultifactorAuthenticationBypassProvider

use of org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider in project cas by apereo.

the class DefaultChainingMultifactorAuthenticationProvider method getBypassEvaluator.

@Override
public MultifactorAuthenticationProviderBypassEvaluator getBypassEvaluator() {
    val bypass = new DefaultChainingMultifactorAuthenticationBypassProvider();
    getMultifactorAuthenticationProviders().stream().sorted(OrderComparator.INSTANCE).map(MultifactorAuthenticationProvider::getBypassEvaluator).forEach(bypass::addMultifactorAuthenticationProviderBypassEvaluator);
    return bypass;
}
Also used : lombok.val(lombok.val) DefaultChainingMultifactorAuthenticationBypassProvider(org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider)

Example 5 with DefaultChainingMultifactorAuthenticationBypassProvider

use of org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider in project cas by apereo.

the class DefaultChainingMultifactorAuthenticationBypassProviderTests method verifyEmptyChainOperation.

@Test
public void verifyEmptyChainOperation() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    val p = new DefaultChainingMultifactorAuthenticationBypassProvider();
    val res = p.filterMultifactorAuthenticationProviderBypassEvaluatorsBy("unknown");
    val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
    val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser");
    val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal);
    val service = MultifactorAuthenticationTestUtils.getRegisteredService();
    assertTrue(res.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, new MockHttpServletRequest()));
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultChainingMultifactorAuthenticationBypassProvider(org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)23 DefaultChainingMultifactorAuthenticationBypassProvider (org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider)23 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)19 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)19 Bean (org.springframework.context.annotation.Bean)19 HttpRequestMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.HttpRequestMultifactorAuthenticationProviderBypassEvaluator)8 RegisteredServiceMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.RegisteredServiceMultifactorAuthenticationProviderBypassEvaluator)8 StringUtils (org.apache.commons.lang3.StringUtils)7 DuoSecurityAuthenticationService (org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService)7 AuthenticationMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.AuthenticationMultifactorAuthenticationProviderBypassEvaluator)7 ChainingMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.ChainingMultifactorAuthenticationProviderBypassEvaluator)7 CredentialMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.CredentialMultifactorAuthenticationProviderBypassEvaluator)7 GroovyMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.GroovyMultifactorAuthenticationProviderBypassEvaluator)7 MultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.MultifactorAuthenticationProviderBypassEvaluator)7 NeverAllowMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.NeverAllowMultifactorAuthenticationProviderBypassEvaluator)7 PrincipalMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.PrincipalMultifactorAuthenticationProviderBypassEvaluator)7 RegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.RegisteredServicePrincipalAttributeMultifactorAuthenticationProviderBypassEvaluator)7 RestMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.RestMultifactorAuthenticationProviderBypassEvaluator)7 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)7 CasFeatureModule (org.apereo.cas.configuration.support.CasFeatureModule)7