Performance: Securing actuator endpoints
This affects the initial page load speed and interaction responsiveness by controlling access to sensitive management endpoints.
management.endpoints.web.exposure.include=health,info
spring.security.user.name=admin
spring.security.user.password=strongpassword
# Secure actuator endpoints with basic authentication and limit exposuremanagement.endpoints.web.exposure.include=*
# No authentication or authorization configured for actuator endpoints| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unsecured actuator endpoints | N/A | N/A | N/A | [X] Bad |
| Secured and limited actuator endpoints | N/A | N/A | N/A | [OK] Good |
application.properties?management.endpoints.web.exposure.include.health,info is correct.http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/actuator/**").hasRole("ADMIN")
.anyRequest().authenticated()
)@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/actuator/**").authenticated()
.anyRequest().permitAll()
);
return http.build();
}management.endpoints.web.exposure.include=health to expose only health publicly./actuator/health and require ADMIN role for other actuator endpoints using requestMatchers.Pass the test and this pattern moves unknown