Search in sources :

Example 81 with RefreshScope

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

the class CasCookieConfiguration method cookieCipherExecutor.

@ConditionalOnMissingBean(name = "cookieCipherExecutor")
@RefreshScope
@Bean
public CipherExecutor cookieCipherExecutor() {
    final EncryptionJwtSigningJwtCryptographyProperties crypto = casProperties.getTgc().getCrypto();
    boolean enabled = crypto.isEnabled();
    if (!enabled && (StringUtils.isNotBlank(crypto.getEncryption().getKey())) && StringUtils.isNotBlank(crypto.getSigning().getKey())) {
        LOGGER.warn("Token encryption/signing is not enabled explicitly in the configuration, yet signing/encryption keys " + "are defined for operations. CAS will proceed to enable the cookie encryption/signing functionality.");
        enabled = true;
    }
    if (enabled) {
        return new TicketGrantingCookieCipherExecutor(crypto.getEncryption().getKey(), crypto.getSigning().getKey(), crypto.getAlg());
    }
    LOGGER.warn("Ticket-granting cookie encryption/signing is turned off. This " + "MAY NOT be safe in a production environment. Consider using other choices to handle encryption, " + "signing and verification of ticket-granting cookies.");
    return CipherExecutor.noOp();
}
Also used : TicketGrantingCookieCipherExecutor(org.apereo.cas.util.cipher.TicketGrantingCookieCipherExecutor) EncryptionJwtSigningJwtCryptographyProperties(org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties) 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 82 with RefreshScope

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

the class CasCoreAuthenticationHandlersConfiguration method acceptUsersAuthenticationHandler.

@RefreshScope
@Bean
public AuthenticationHandler acceptUsersAuthenticationHandler() {
    final AcceptAuthenticationProperties props = casProperties.getAuthn().getAccept();
    final AcceptUsersAuthenticationHandler h = new AcceptUsersAuthenticationHandler(props.getName(), servicesManager, acceptUsersPrincipalFactory(), null, getParsedUsers());
    h.setPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(props.getPasswordEncoder()));
    if (acceptPasswordPolicyConfiguration != null) {
        h.setPasswordPolicyConfiguration(acceptPasswordPolicyConfiguration);
    }
    h.setCredentialSelectionPredicate(CoreAuthenticationUtils.newCredentialSelectionPredicate(props.getCredentialCriteria()));
    h.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(props.getPrincipalTransformation()));
    return h;
}
Also used : AcceptUsersAuthenticationHandler(org.apereo.cas.authentication.AcceptUsersAuthenticationHandler) AcceptAuthenticationProperties(org.apereo.cas.configuration.model.support.generic.AcceptAuthenticationProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 83 with RefreshScope

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

the class CasCoreAuthenticationSupportConfiguration method authenticationContextValidator.

@RefreshScope
@Bean
@ConditionalOnMissingBean(name = "authenticationContextValidator")
public AuthenticationContextValidator authenticationContextValidator() {
    final MultifactorAuthenticationProperties mfa = casProperties.getAuthn().getMfa();
    final String contextAttribute = mfa.getAuthenticationContextAttribute();
    final String failureMode = mfa.getGlobalFailureMode();
    final String authnAttributeName = mfa.getTrusted().getAuthenticationContextAttribute();
    return new DefaultAuthenticationContextValidator(contextAttribute, failureMode, authnAttributeName);
}
Also used : MultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties) DefaultAuthenticationContextValidator(org.apereo.cas.authentication.DefaultAuthenticationContextValidator) 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 84 with RefreshScope

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

the class U2FConfiguration method u2fRegistrationRecordCipherExecutor.

@Bean
@RefreshScope
public CipherExecutor u2fRegistrationRecordCipherExecutor() {
    final EncryptionJwtSigningJwtCryptographyProperties crypto = casProperties.getAuthn().getMfa().getU2f().getCrypto();
    if (crypto.isEnabled()) {
        return new U2FAuthenticationRegistrationRecordCipherExecutor(crypto.getEncryption().getKey(), crypto.getSigning().getKey(), crypto.getAlg());
    }
    LOGGER.info("U2F registration record encryption/signing is turned off and " + "MAY NOT be safe in a production environment. " + "Consider using other choices to handle encryption, signing and verification of " + "U2F registration records for MFA");
    return CipherExecutor.noOp();
}
Also used : U2FAuthenticationRegistrationRecordCipherExecutor(org.apereo.cas.adaptors.u2f.U2FAuthenticationRegistrationRecordCipherExecutor) EncryptionJwtSigningJwtCryptographyProperties(org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 85 with RefreshScope

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

the class U2FAuthenticationEventExecutionPlanConfiguration method u2fAuthenticationProvider.

@Bean
@RefreshScope
public MultifactorAuthenticationProvider u2fAuthenticationProvider() {
    final U2FMultifactorAuthenticationProvider p = new U2FMultifactorAuthenticationProvider();
    p.setBypassEvaluator(u2fBypassEvaluator());
    p.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
    p.setOrder(casProperties.getAuthn().getMfa().getU2f().getRank());
    p.setId(casProperties.getAuthn().getMfa().getU2f().getId());
    return p;
}
Also used : U2FMultifactorAuthenticationProvider(org.apereo.cas.adaptors.u2f.U2FMultifactorAuthenticationProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) 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