Search in sources :

Example 1 with CasSecurityInterceptor

use of org.apereo.cas.web.pac4j.CasSecurityInterceptor in project cas by apereo.

the class CasSecurityContextConfiguration method requiresAuthenticationStatusAdminEndpointsInterceptor.

@RefreshScope
@Bean
public SecurityInterceptor requiresAuthenticationStatusAdminEndpointsInterceptor() {
    final Config cfg = casAdminPagesPac4jConfig();
    if (cfg.getClients() == null) {
        return requiresAuthenticationStatusInterceptor();
    }
    final CasSecurityInterceptor interceptor = new CasSecurityInterceptor(cfg, CAS_CLIENT_NAME, "securityHeaders,csrfToken,".concat(getAuthorizerName()));
    return interceptor;
}
Also used : Config(org.pac4j.core.config.Config) CasSecurityInterceptor(org.apereo.cas.web.pac4j.CasSecurityInterceptor) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 2 with CasSecurityInterceptor

use of org.apereo.cas.web.pac4j.CasSecurityInterceptor in project cas by apereo.

the class CasSecurityContextConfiguration method requiresAuthenticationStatusInterceptor.

@RefreshScope
@Bean
public SecurityInterceptor requiresAuthenticationStatusInterceptor() {
    final AdminPagesSecurityProperties secProps = casProperties.getAdminPagesSecurity();
    final IpRegexpAuthenticator authn = new IpRegexpAuthenticator(secProps.getIp());
    final IpClient ipClient = new IpClient(authn);
    final Set<String> headerNames = org.springframework.util.StringUtils.commaDelimitedListToSet(secProps.getAlternateIpHeaderName());
    final IpExtractor credentialsExtractor = new IpExtractor(headerNames.toArray(new String[] {}));
    ipClient.setCredentialsExtractor(credentialsExtractor);
    return new CasSecurityInterceptor(new Config(ipClient), ipClient.getClass().getSimpleName());
}
Also used : IpRegexpAuthenticator(org.pac4j.http.credentials.authenticator.IpRegexpAuthenticator) IpClient(org.pac4j.http.client.direct.IpClient) IpExtractor(org.pac4j.http.credentials.extractor.IpExtractor) Config(org.pac4j.core.config.Config) CasSecurityInterceptor(org.apereo.cas.web.pac4j.CasSecurityInterceptor) AdminPagesSecurityProperties(org.apereo.cas.configuration.model.core.web.security.AdminPagesSecurityProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Aggregations

CasSecurityInterceptor (org.apereo.cas.web.pac4j.CasSecurityInterceptor)2 Config (org.pac4j.core.config.Config)2 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)2 Bean (org.springframework.context.annotation.Bean)2 AdminPagesSecurityProperties (org.apereo.cas.configuration.model.core.web.security.AdminPagesSecurityProperties)1 IpClient (org.pac4j.http.client.direct.IpClient)1 IpRegexpAuthenticator (org.pac4j.http.credentials.authenticator.IpRegexpAuthenticator)1 IpExtractor (org.pac4j.http.credentials.extractor.IpExtractor)1