Skip to content
Snippets Groups Projects
Commit 34a4d337 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

WIP: Restrict access to /management endpoint to ROLE_ADMIN

parent f363f4d5
No related merge requests found
Pipeline #29569 failed with stages
in 40 seconds
This commit is part of merge request !140. Comments created here will be created in the context of that merge request.
...@@ -32,6 +32,7 @@ import org.pac4j.oidc.client.OidcClient; ...@@ -32,6 +32,7 @@ import org.pac4j.oidc.client.OidcClient;
import org.pac4j.oidc.config.OidcConfiguration; import org.pac4j.oidc.config.OidcConfiguration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -145,6 +146,25 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -145,6 +146,25 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
} }
} }
@Configuration
@Order(3)
@Profile("!test")
public class ManagementHttpSecurityConfig extends HttpSecurityConfig {
private final String managementPath;
public ManagementHttpSecurityConfig(final WebEndpointProperties webEndpointProperties) {
managementPath = webEndpointProperties.getBasePath();
}
@Override
protected void configure(final HttpSecurity http) throws Exception {
super.configure(http);
http.antMatcher(managementPath);
http.authorizeRequests().anyRequest().hasRole("ADMIN");
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
@Configuration @Configuration
@Order(2) @Order(2)
@Profile("!test") @Profile("!test")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment