Search in sources :

Example 1 with DefaultMultifactorAuthenticationProviderBypass

use of org.apereo.cas.services.DefaultMultifactorAuthenticationProviderBypass in project cas by apereo.

the class DuoSecurityAuthenticationEventExecutionPlanConfiguration method duoMultifactorAuthenticationProvider.

@Bean
@RefreshScope
public VariegatedMultifactorAuthenticationProvider duoMultifactorAuthenticationProvider() {
    final DefaultVariegatedMultifactorAuthenticationProvider provider = new DefaultVariegatedMultifactorAuthenticationProvider();
    casProperties.getAuthn().getMfa().getDuo().stream().filter(duo -> StringUtils.isNotBlank(duo.getDuoApiHost()) && StringUtils.isNotBlank(duo.getDuoIntegrationKey()) && StringUtils.isNotBlank(duo.getDuoSecretKey()) && StringUtils.isNotBlank(duo.getDuoApplicationKey())).forEach(duo -> {
        final BasicDuoAuthenticationService s = new BasicDuoAuthenticationService(duo, httpClient);
        final DefaultDuoMultifactorAuthenticationProvider pWeb = new DefaultDuoMultifactorAuthenticationProvider(s);
        pWeb.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
        pWeb.setBypassEvaluator(new DefaultMultifactorAuthenticationProviderBypass(duo.getBypass()));
        pWeb.setOrder(duo.getRank());
        pWeb.setId(duo.getId());
        provider.addProvider(pWeb);
    });
    if (provider.getProviders().isEmpty()) {
        throw new IllegalArgumentException("At least one Duo instance must be defined");
    }
    return provider;
}
Also used : PrepareDuoWebLoginFormAction(org.apereo.cas.adaptors.duo.web.flow.action.PrepareDuoWebLoginFormAction) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) DefaultVariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.DefaultVariegatedMultifactorAuthenticationProvider) AuthenticationMetaDataPopulator(org.apereo.cas.authentication.AuthenticationMetaDataPopulator) Ordered(org.springframework.core.Ordered) HttpClient(org.apereo.cas.util.http.HttpClient) DuoMultifactorWebflowConfigurer(org.apereo.cas.adaptors.duo.web.flow.config.DuoMultifactorWebflowConfigurer) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) DefaultDuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) StringUtils(org.apache.commons.lang3.StringUtils) AuthenticationEventExecutionPlan(org.apereo.cas.authentication.AuthenticationEventExecutionPlan) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) PrincipalFactory(org.apereo.cas.authentication.principal.PrincipalFactory) MultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties) BeanCreationException(org.springframework.beans.factory.BeanCreationException) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) BasicDuoAuthenticationService(org.apereo.cas.adaptors.duo.authn.BasicDuoAuthenticationService) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DuoAuthenticationHandler(org.apereo.cas.adaptors.duo.authn.DuoAuthenticationHandler) VariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider) ServicesManager(org.apereo.cas.services.ServicesManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Order(org.springframework.core.annotation.Order) AuthenticationContextAttributeMetaDataPopulator(org.apereo.cas.authentication.metadata.AuthenticationContextAttributeMetaDataPopulator) Logger(org.slf4j.Logger) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) AutoConfigureOrder(org.springframework.boot.autoconfigure.AutoConfigureOrder) Action(org.springframework.webflow.execution.Action) AuthenticationEventExecutionPlanConfigurer(org.apereo.cas.config.support.authentication.AuthenticationEventExecutionPlanConfigurer) DefaultMultifactorAuthenticationProviderBypass(org.apereo.cas.services.DefaultMultifactorAuthenticationProviderBypass) Configuration(org.springframework.context.annotation.Configuration) List(java.util.List) CasWebflowConfigurer(org.apereo.cas.web.flow.CasWebflowConfigurer) Bean(org.springframework.context.annotation.Bean) DefaultPrincipalFactory(org.apereo.cas.authentication.principal.DefaultPrincipalFactory) BasicDuoAuthenticationService(org.apereo.cas.adaptors.duo.authn.BasicDuoAuthenticationService) DefaultMultifactorAuthenticationProviderBypass(org.apereo.cas.services.DefaultMultifactorAuthenticationProviderBypass) DefaultDuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider) DefaultVariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.DefaultVariegatedMultifactorAuthenticationProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

List (java.util.List)1 StringUtils (org.apache.commons.lang3.StringUtils)1 BasicDuoAuthenticationService (org.apereo.cas.adaptors.duo.authn.BasicDuoAuthenticationService)1 DefaultDuoMultifactorAuthenticationProvider (org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider)1 DuoAuthenticationHandler (org.apereo.cas.adaptors.duo.authn.DuoAuthenticationHandler)1 PrepareDuoWebLoginFormAction (org.apereo.cas.adaptors.duo.web.flow.action.PrepareDuoWebLoginFormAction)1 DuoMultifactorWebflowConfigurer (org.apereo.cas.adaptors.duo.web.flow.config.DuoMultifactorWebflowConfigurer)1 AuthenticationEventExecutionPlan (org.apereo.cas.authentication.AuthenticationEventExecutionPlan)1 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)1 AuthenticationMetaDataPopulator (org.apereo.cas.authentication.AuthenticationMetaDataPopulator)1 AuthenticationContextAttributeMetaDataPopulator (org.apereo.cas.authentication.metadata.AuthenticationContextAttributeMetaDataPopulator)1 DefaultPrincipalFactory (org.apereo.cas.authentication.principal.DefaultPrincipalFactory)1 PrincipalFactory (org.apereo.cas.authentication.principal.PrincipalFactory)1 AuthenticationEventExecutionPlanConfigurer (org.apereo.cas.config.support.authentication.AuthenticationEventExecutionPlanConfigurer)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 MultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties)1 DefaultMultifactorAuthenticationProviderBypass (org.apereo.cas.services.DefaultMultifactorAuthenticationProviderBypass)1 DefaultVariegatedMultifactorAuthenticationProvider (org.apereo.cas.services.DefaultVariegatedMultifactorAuthenticationProvider)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 VariegatedMultifactorAuthenticationProvider (org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider)1