Skip to content

Commit d07e351

Browse files
committed
Polish " Change info endpoint to be secure and unexposed by default"
See gh-24715
1 parent 53c1e79 commit d07e351

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/ReactiveManagementWebSecurityAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
2121
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
2222
import org.springframework.boot.actuate.health.HealthEndpoint;
23-
import org.springframework.boot.actuate.info.InfoEndpoint;
2423
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
2524
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
2625
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -40,8 +39,8 @@
4039

4140
/**
4241
* {@link EnableAutoConfiguration Auto-configuration} for Reactive Spring Security when
43-
* actuator is on the classpath. Specifically, it permits access to the health and info
44-
* endpoints while securing everything else.
42+
* actuator is on the classpath. Specifically, it permits access to the health endpoint
43+
* while securing everything else.
4544
*
4645
* @author Madhura Bhave
4746
* @since 2.1.0
@@ -59,7 +58,7 @@ public class ReactiveManagementWebSecurityAutoConfiguration {
5958
@Bean
6059
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
6160
http.authorizeExchange((exchanges) -> {
62-
exchanges.matchers(EndpointRequest.to(HealthEndpoint.class, InfoEndpoint.class)).permitAll();
61+
exchanges.matchers(EndpointRequest.to(HealthEndpoint.class)).permitAll();
6362
exchanges.anyExchange().authenticated();
6463
});
6564
http.httpBasic(Customizer.withDefaults());

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfigurationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ class InfoEndpointAutoConfigurationTests {
3434
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3535
.withConfiguration(AutoConfigurations.of(InfoEndpointAutoConfiguration.class));
3636

37+
@Test
38+
void runShouldHaveEndpointBean() {
39+
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=info")
40+
.run((context) -> assertThat(context).hasSingleBean(InfoEndpoint.class));
41+
}
42+
43+
@Test
44+
void runWhenNotExposedShouldNotHaveEndpointBean() {
45+
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(InfoEndpoint.class));
46+
}
47+
3748
@Test
3849
void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
3950
this.contextRunner.withPropertyValues("management.endpoint.info.enabled:false")

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ void healthInsecureByDefault() {
5050
.isOk();
5151
}
5252

53-
@Test
54-
void infoInsecureByDefault() {
55-
this.webClient.get().uri("/actuator/info").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk();
56-
}
57-
5853
@Test
5954
void otherActuatorsSecureByDefault() {
6055
this.webClient.get().uri("/actuator/env").accept(MediaType.APPLICATION_JSON).exchange().expectStatus()

0 commit comments

Comments
 (0)