Search in sources :

Example 1 with VariegatedMultifactorAuthenticationProvider

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

the class DuoSecurityAuthenticationEventExecutionPlanConfiguration method duoMultifactorAuthenticationProvider.

@ConditionalOnMissingBean(name = "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 BasicDuoSecurityAuthenticationService s = new BasicDuoSecurityAuthenticationService(duo, httpClient);
        final DefaultDuoMultifactorAuthenticationProvider duoP = new DefaultDuoMultifactorAuthenticationProvider(duo.getRegistrationUrl(), s);
        duoP.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
        duoP.setBypassEvaluator(MultifactorAuthenticationUtils.newMultifactorAuthenticationProviderBypass(duo.getBypass()));
        duoP.setOrder(duo.getRank());
        duoP.setId(duo.getId());
        provider.addProvider(duoP);
    });
    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) AuthenticationMetaDataPopulator(org.apereo.cas.authentication.AuthenticationMetaDataPopulator) ByCredentialTypeAuthenticationHandlerResolver(org.apereo.cas.authentication.ByCredentialTypeAuthenticationHandlerResolver) HttpClient(org.apereo.cas.util.http.HttpClient) DuoMultifactorWebflowConfigurer(org.apereo.cas.adaptors.duo.web.flow.config.DuoMultifactorWebflowConfigurer) CasWebflowExecutionPlan(org.apereo.cas.web.flow.CasWebflowExecutionPlan) Autowired(org.springframework.beans.factory.annotation.Autowired) DependsOn(org.springframework.context.annotation.DependsOn) DefaultDuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) StringUtils(org.apache.commons.lang3.StringUtils) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) DetermineDuoUserAccountAction(org.apereo.cas.adaptors.duo.web.flow.action.DetermineDuoUserAccountAction) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) PrincipalFactory(org.apereo.cas.authentication.principal.PrincipalFactory) BeanCreationException(org.springframework.beans.factory.BeanCreationException) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DuoAuthenticationHandler(org.apereo.cas.adaptors.duo.authn.DuoAuthenticationHandler) MultifactorAuthenticationUtils(org.apereo.cas.authentication.MultifactorAuthenticationUtils) VariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider) DuoDirectCredential(org.apereo.cas.adaptors.duo.authn.DuoDirectCredential) ServicesManager(org.apereo.cas.services.ServicesManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) AuthenticationContextAttributeMetaDataPopulator(org.apereo.cas.authentication.metadata.AuthenticationContextAttributeMetaDataPopulator) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) DuoSecurityMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorProperties) BasicDuoSecurityAuthenticationService(org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService) DuoCredential(org.apereo.cas.adaptors.duo.authn.DuoCredential) DefaultVariegatedMultifactorAuthenticationProvider(org.apereo.cas.authentication.DefaultVariegatedMultifactorAuthenticationProvider) Action(org.springframework.webflow.execution.Action) ApplicationContext(org.springframework.context.ApplicationContext) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) CasWebflowConfigurer(org.apereo.cas.web.flow.CasWebflowConfigurer) Bean(org.springframework.context.annotation.Bean) AuthenticationEventExecutionPlanConfigurer(org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer) CasWebflowExecutionPlanConfigurer(org.apereo.cas.web.flow.CasWebflowExecutionPlanConfigurer) DefaultPrincipalFactory(org.apereo.cas.authentication.principal.DefaultPrincipalFactory) BasicDuoSecurityAuthenticationService(org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService) DefaultDuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider) DefaultVariegatedMultifactorAuthenticationProvider(org.apereo.cas.authentication.DefaultVariegatedMultifactorAuthenticationProvider) 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)

Aggregations

List (java.util.List)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 BasicDuoSecurityAuthenticationService (org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService)1 DefaultDuoMultifactorAuthenticationProvider (org.apereo.cas.adaptors.duo.authn.DefaultDuoMultifactorAuthenticationProvider)1 DuoAuthenticationHandler (org.apereo.cas.adaptors.duo.authn.DuoAuthenticationHandler)1 DuoCredential (org.apereo.cas.adaptors.duo.authn.DuoCredential)1 DuoDirectCredential (org.apereo.cas.adaptors.duo.authn.DuoDirectCredential)1 DetermineDuoUserAccountAction (org.apereo.cas.adaptors.duo.web.flow.action.DetermineDuoUserAccountAction)1 PrepareDuoWebLoginFormAction (org.apereo.cas.adaptors.duo.web.flow.action.PrepareDuoWebLoginFormAction)1 DuoMultifactorWebflowConfigurer (org.apereo.cas.adaptors.duo.web.flow.config.DuoMultifactorWebflowConfigurer)1 AuthenticationEventExecutionPlanConfigurer (org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer)1 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)1 AuthenticationMetaDataPopulator (org.apereo.cas.authentication.AuthenticationMetaDataPopulator)1 ByCredentialTypeAuthenticationHandlerResolver (org.apereo.cas.authentication.ByCredentialTypeAuthenticationHandlerResolver)1 DefaultVariegatedMultifactorAuthenticationProvider (org.apereo.cas.authentication.DefaultVariegatedMultifactorAuthenticationProvider)1 MultifactorAuthenticationUtils (org.apereo.cas.authentication.MultifactorAuthenticationUtils)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