Search in sources :

Example 1 with WebSecurity

use of org.springframework.security.config.annotation.web.builders.WebSecurity in project promregator by promregator.

the class SecurityConfig method determineWebSecurityForEndpoint.

private WebSecurity determineWebSecurityForEndpoint(WebSecurity secInitial, String endpoint, InboundAuthorizationMode iam) throws Exception {
    WebSecurity sec = secInitial;
    if (iam == InboundAuthorizationMode.NONE) {
        System.err.println(String.format("Endpoint %s is NOT authentication protected", endpoint));
        sec = sec.ignoring().antMatchers(endpoint).and();
    }
    return sec;
}
Also used : WebSecurity(org.springframework.security.config.annotation.web.builders.WebSecurity) EnableWebSecurity(org.springframework.security.config.annotation.web.configuration.EnableWebSecurity)

Example 2 with WebSecurity

use of org.springframework.security.config.annotation.web.builders.WebSecurity in project promregator by promregator.

the class SecurityConfig method configure.

// see also
// https://stackoverflow.com/questions/30366405/how-to-disable-spring-security-for-particular-url
@Override
public void configure(WebSecurity webInitial) throws Exception {
    if (!this.isInboundAuthSecurityEnabled()) {
        return;
    }
    WebSecurity web = webInitial;
    web = this.determineWebSecurityForEndpoint(web, "/discovery", this.discoveryAuth);
    web = this.determineWebSecurityForEndpoint(web, "/metrics", this.endpointAuth);
    web = this.determineWebSecurityForEndpoint(web, "/singleTargetMetrics/**", this.endpointAuth);
    web = this.determineWebSecurityForEndpoint(web, "/promregatorMetrics", this.promregatorMetricsAuth);
}
Also used : WebSecurity(org.springframework.security.config.annotation.web.builders.WebSecurity) EnableWebSecurity(org.springframework.security.config.annotation.web.configuration.EnableWebSecurity)

Aggregations

WebSecurity (org.springframework.security.config.annotation.web.builders.WebSecurity)2 EnableWebSecurity (org.springframework.security.config.annotation.web.configuration.EnableWebSecurity)2