Search in sources :

Example 46 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope 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)

Example 47 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class DuoSecurityAuthenticationEventExecutionPlanConfiguration method duoAuthenticationHandler.

@RefreshScope
@Bean
public AuthenticationHandler duoAuthenticationHandler() {
    final List<DuoSecurityMultifactorProperties> duos = casProperties.getAuthn().getMfa().getDuo();
    if (duos.isEmpty()) {
        throw new BeanCreationException("No configuration/settings could be found for Duo Security. Review settings and ensure the correct syntax is used");
    }
    final String name = duos.get(0).getName();
    if (duos.size() > 1) {
        LOGGER.debug("Multiple Duo Security providers are available; Duo authentication handler is named after [{}]", name);
    }
    final DuoAuthenticationHandler h = new DuoAuthenticationHandler(name, servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProvider());
    return h;
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) DuoSecurityMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorProperties) DuoAuthenticationHandler(org.apereo.cas.adaptors.duo.authn.DuoAuthenticationHandler) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 48 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class DynamoDbTicketRegistryConfiguration method amazonDynamoDbClient.

@RefreshScope
@Bean
@SneakyThrows
public AmazonDynamoDB amazonDynamoDbClient() {
    final DynamoDbTicketRegistryProperties dynamoDbProperties = casProperties.getTicket().getRegistry().getDynamoDb();
    final AmazonDynamoDbClientFactory factory = new AmazonDynamoDbClientFactory();
    return factory.createAmazonDynamoDb(dynamoDbProperties);
}
Also used : AmazonDynamoDbClientFactory(org.apereo.cas.dynamodb.AmazonDynamoDbClientFactory) DynamoDbTicketRegistryProperties(org.apereo.cas.configuration.model.support.dynamodb.DynamoDbTicketRegistryProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) Bean(org.springframework.context.annotation.Bean)

Example 49 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class DynamoDbTicketRegistryConfiguration method ticketRegistry.

@Autowired
@RefreshScope
@Bean
public TicketRegistry ticketRegistry(@Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) {
    final DynamoDbTicketRegistryProperties db = casProperties.getTicket().getRegistry().getDynamoDb();
    final EncryptionRandomizedSigningJwtCryptographyProperties crypto = db.getCrypto();
    return new DynamoDbTicketRegistry(CoreTicketUtils.newTicketRegistryCipherExecutor(crypto, "dynamoDb"), dynamoDbTicketRegistryFacilitator(ticketCatalog));
}
Also used : DynamoDbTicketRegistryProperties(org.apereo.cas.configuration.model.support.dynamodb.DynamoDbTicketRegistryProperties) DynamoDbTicketRegistry(org.apereo.cas.ticket.registry.DynamoDbTicketRegistry) EncryptionRandomizedSigningJwtCryptographyProperties(org.apereo.cas.configuration.model.core.util.EncryptionRandomizedSigningJwtCryptographyProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Example 50 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class DynamoDbTicketRegistryConfiguration method dynamoDbTicketRegistryFacilitator.

@Autowired
@RefreshScope
@Bean
public DynamoDbTicketRegistryFacilitator dynamoDbTicketRegistryFacilitator(@Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) {
    final DynamoDbTicketRegistryProperties db = casProperties.getTicket().getRegistry().getDynamoDb();
    final DynamoDbTicketRegistryFacilitator f = new DynamoDbTicketRegistryFacilitator(ticketCatalog, db, amazonDynamoDbClient());
    f.createTicketTables(db.isDropTablesOnStartup());
    return f;
}
Also used : DynamoDbTicketRegistryFacilitator(org.apereo.cas.ticket.registry.DynamoDbTicketRegistryFacilitator) DynamoDbTicketRegistryProperties(org.apereo.cas.configuration.model.support.dynamodb.DynamoDbTicketRegistryProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Aggregations

RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)167 Bean (org.springframework.context.annotation.Bean)167 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)114 Autowired (org.springframework.beans.factory.annotation.Autowired)20 ArrayList (java.util.ArrayList)15 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)11 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)11 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)8 EncryptionJwtSigningJwtCryptographyProperties (org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties)8 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)8 List (java.util.List)7 SneakyThrows (lombok.SneakyThrows)7 IPersonAttributeDao (org.apereo.services.persondir.IPersonAttributeDao)7 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)7 ConnectionFactory (org.ldaptive.ConnectionFactory)6 Resource (org.springframework.core.io.Resource)5 Properties (java.util.Properties)4 GrouperPrincipalAttributesProperties (org.apereo.cas.configuration.model.core.authentication.GrouperPrincipalAttributesProperties)4 PrincipalAttributesProperties (org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesProperties)4 IgniteProperties (org.apereo.cas.configuration.model.support.ignite.IgniteProperties)4