Search in sources :

Example 1 with IpExtractor

use of org.pac4j.http.credentials.extractor.IpExtractor 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

AdminPagesSecurityProperties (org.apereo.cas.configuration.model.core.web.security.AdminPagesSecurityProperties)1 CasSecurityInterceptor (org.apereo.cas.web.pac4j.CasSecurityInterceptor)1 Config (org.pac4j.core.config.Config)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 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1