DevActuatorConfiguration.java
package com.project.auth.config.web;
import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository;
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@Profile("dev")
public class DevActuatorConfiguration {
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SecurityFilterChain actuatorSecurityFilterChain(HttpSecurity http) throws Exception {
return http
.securityMatcher("/actuator", "/actuator/**")
.authorizeHttpRequests(authorize -> authorize
.requestMatchers(
"/actuator",
"/actuator/health",
"/actuator/health/**",
"/actuator/info",
"/actuator/loggers",
"/actuator/loggers/**",
"/actuator/httpexchanges",
"/actuator/httpexchanges/**"
).permitAll()
.anyRequest().denyAll()
)
.csrf(csrf -> csrf.disable())
.build();
}
@Bean
public HttpExchangeRepository httpExchangeRepository() {
return new InMemoryHttpExchangeRepository();
}
}