Search in sources :

Example 1 with EndpointRequest

use of org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest in project cas by apereo.

the class CasWebSecurityConfigurerAdapter method configureEndpointAccessToDenyUndefined.

/**
 * Configure endpoint access to deny undefined.
 *
 * @param http     the http
 * @param requests the requests
 */
protected void configureEndpointAccessToDenyUndefined(final HttpSecurity http, final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) {
    val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint().keySet();
    val endpointDefaults = casProperties.getMonitor().getEndpoints().getDefaultEndpointProperties();
    pathMappedEndpoints.getObject().forEach(endpoint -> {
        val rootPath = endpoint.getRootPath();
        if (endpoints.contains(rootPath)) {
            LOGGER.trace("Endpoint security is defined for endpoint [{}]", rootPath);
        } else {
            val defaultAccessRules = endpointDefaults.getAccess();
            LOGGER.trace("Endpoint security is NOT defined for endpoint [{}]. Using default security rules [{}]", rootPath, endpointDefaults);
            val endpointRequest = EndpointRequest.to(rootPath).excludingLinks();
            defaultAccessRules.forEach(Unchecked.consumer(access -> configureEndpointAccess(http, requests, access, endpointDefaults, endpointRequest)));
        }
    });
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) JaasSecurityActuatorEndpointsMonitorProperties(org.apereo.cas.configuration.model.core.monitor.JaasSecurityActuatorEndpointsMonitorProperties) EndpointLdapAuthenticationProvider(org.apereo.cas.web.security.authentication.EndpointLdapAuthenticationProvider) SneakyThrows(lombok.SneakyThrows) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity) StringUtils(org.apache.commons.lang3.StringUtils) BeanSupplier(org.apereo.cas.util.spring.beans.BeanSupplier) WebSecurityConfigurerAdapter(org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter) ObjectProvider(org.springframework.beans.factory.ObjectProvider) AuthenticationManagerBuilder(org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder) ProtocolEndpointWebSecurityConfigurer(org.apereo.cas.web.ProtocolEndpointWebSecurityConfigurer) JaasAuthenticationProvider(org.springframework.security.authentication.jaas.JaasAuthenticationProvider) SecurityExpressionHandler(org.springframework.security.access.expression.SecurityExpressionHandler) SecurityProperties(org.springframework.boot.autoconfigure.security.SecurityProperties) Order(org.springframework.core.annotation.Order) PathRequest(org.springframework.boot.autoconfigure.security.servlet.PathRequest) Unchecked(org.jooq.lambda.Unchecked) ExpressionUrlAuthorizationConfigurer(org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer) lombok.val(lombok.val) EndpointRequest(org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest) Collectors(java.util.stream.Collectors) LdapSecurityActuatorEndpointsMonitorProperties(org.apereo.cas.configuration.model.core.monitor.LdapSecurityActuatorEndpointsMonitorProperties) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) CasWebSecurityConstants(org.apereo.cas.web.CasWebSecurityConstants) ActuatorEndpointProperties(org.apereo.cas.configuration.model.core.monitor.ActuatorEndpointProperties) DisposableBean(org.springframework.beans.factory.DisposableBean) FilterInvocation(org.springframework.security.web.FilterInvocation) PathMappedEndpoints(org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints) LdapUtils(org.apereo.cas.util.LdapUtils)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 SneakyThrows (lombok.SneakyThrows)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 ActuatorEndpointProperties (org.apereo.cas.configuration.model.core.monitor.ActuatorEndpointProperties)1 JaasSecurityActuatorEndpointsMonitorProperties (org.apereo.cas.configuration.model.core.monitor.JaasSecurityActuatorEndpointsMonitorProperties)1 LdapSecurityActuatorEndpointsMonitorProperties (org.apereo.cas.configuration.model.core.monitor.LdapSecurityActuatorEndpointsMonitorProperties)1 LdapUtils (org.apereo.cas.util.LdapUtils)1 BeanSupplier (org.apereo.cas.util.spring.beans.BeanSupplier)1 CasWebSecurityConstants (org.apereo.cas.web.CasWebSecurityConstants)1 ProtocolEndpointWebSecurityConfigurer (org.apereo.cas.web.ProtocolEndpointWebSecurityConfigurer)1 EndpointLdapAuthenticationProvider (org.apereo.cas.web.security.authentication.EndpointLdapAuthenticationProvider)1 Unchecked (org.jooq.lambda.Unchecked)1 DisposableBean (org.springframework.beans.factory.DisposableBean)1 ObjectProvider (org.springframework.beans.factory.ObjectProvider)1