diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java index ddb5a5cd42..b834c4208b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java @@ -44,7 +44,7 @@ public class ExposeExcludePropertyEndpointFilter> private final Class endpointType; - private final Set expose; + private final Set include; private final Set exclude; @@ -57,17 +57,17 @@ public class ExposeExcludePropertyEndpointFilter> Assert.hasText(prefix, "Prefix must not be empty"); Binder binder = Binder.get(environment); this.endpointType = endpointType; - this.expose = bind(binder, prefix + ".expose"); + this.include = bind(binder, prefix + ".expose"); this.exclude = bind(binder, prefix + ".exclude"); this.exposeDefaults = asSet(Arrays.asList(exposeDefaults)); } public ExposeExcludePropertyEndpointFilter(Class endpointType, - Collection expose, Collection exclude, + Collection include, Collection exclude, String... exposeDefaults) { Assert.notNull(endpointType, "EndpointType Type must not be null"); this.endpointType = endpointType; - this.expose = asSet(expose); + this.include = asSet(include); this.exclude = asSet(exclude); this.exposeDefaults = asSet(Arrays.asList(exposeDefaults)); } @@ -94,11 +94,11 @@ public class ExposeExcludePropertyEndpointFilter> } private boolean isExposed(ExposableEndpoint endpoint) { - if (this.expose.isEmpty()) { + if (this.include.isEmpty()) { return this.exposeDefaults.contains("*") || contains(this.exposeDefaults, endpoint); } - return this.expose.contains("*") || contains(this.expose, endpoint); + return this.include.contains("*") || contains(this.include, endpoint); } private boolean isExcluded(ExposableEndpoint endpoint) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java index 3540883c34..ed4dafaf34 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.jmx; import java.util.Collection; import java.util.Collections; -import java.util.Set; import javax.management.MBeanServer; @@ -97,10 +96,9 @@ public class JmxEndpointAutoConfiguration { @Bean public ExposeExcludePropertyEndpointFilter jmxIncludeExcludePropertyEndpointFilter() { - Set expose = this.properties.getExpose(); - Set exclude = this.properties.getExclude(); + JmxEndpointProperties.Exposure exposure = this.properties.getExposure(); return new ExposeExcludePropertyEndpointFilter<>(ExposableJmxEndpoint.class, - expose, exclude, "*"); + exposure.getInclude(), exposure.getExclude(), "*"); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java index 1d74c8998c..ccdc50610a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,7 @@ import org.springframework.util.StringUtils; @ConfigurationProperties("management.endpoints.jmx") public class JmxEndpointProperties { - /** - * Endpoint IDs that should be exposed or '*' for all. - */ - private Set expose = new LinkedHashSet<>(); - - /** - * Endpoint IDs that should be excluded. - */ - private Set exclude = new LinkedHashSet<>(); + private final Exposure exposure = new Exposure(); /** * Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set. @@ -66,20 +58,8 @@ public class JmxEndpointProperties { } } - public Set getExpose() { - return this.expose; - } - - public void setExpose(Set expose) { - this.expose = expose; - } - - public Set getExclude() { - return this.exclude; - } - - public void setExclude(Set exclude) { - this.exclude = exclude; + public Exposure getExposure() { + return this.exposure; } public String getDomain() { @@ -102,4 +82,35 @@ public class JmxEndpointProperties { return this.staticNames; } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java index 299a7d014f..b0acd639a1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web; -import java.util.Set; - import org.springframework.boot.actuate.autoconfigure.endpoint.ExposeExcludePropertyEndpointFilter; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint; @@ -51,10 +49,9 @@ public class ServletEndpointManagementContextConfiguration { @Bean public ExposeExcludePropertyEndpointFilter servletExposeExcludePropertyEndpointFilter( WebEndpointProperties properties) { - Set expose = properties.getExpose(); - Set exclude = properties.getExclude(); + WebEndpointProperties.Exposure exposure = properties.getExposure(); return new ExposeExcludePropertyEndpointFilter<>(ExposableServletEndpoint.class, - expose, exclude); + exposure.getInclude(), exposure.getExclude()); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java index 767e2ce1c2..4de4a65db9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Set; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -125,18 +124,17 @@ public class WebEndpointAutoConfiguration { @Bean public ExposeExcludePropertyEndpointFilter webExposeExcludePropertyEndpointFilter() { - Set expose = this.properties.getExpose(); - Set exclude = this.properties.getExclude(); + WebEndpointProperties.Exposure exposure = this.properties.getExposure(); return new ExposeExcludePropertyEndpointFilter<>(ExposableWebEndpoint.class, - expose, exclude, "info", "health"); + exposure.getInclude(), exposure.getExclude(), "info", "health"); } @Bean public ExposeExcludePropertyEndpointFilter controllerExposeExcludePropertyEndpointFilter() { - Set expose = this.properties.getExpose(); - Set exclude = this.properties.getExclude(); + WebEndpointProperties.Exposure exposure = this.properties.getExposure(); return new ExposeExcludePropertyEndpointFilter<>( - ExposableControllerEndpoint.class, expose, exclude); + ExposableControllerEndpoint.class, exposure.getInclude(), + exposure.getExclude()); } @Configuration diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java index 0ace13355c..d1504e3424 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,27 +34,23 @@ import org.springframework.util.StringUtils; @ConfigurationProperties(prefix = "management.endpoints.web") public class WebEndpointProperties { + private final Exposure exposure = new Exposure(); + /** * Base path for Web endpoints. Relative to server.servlet.context-path or * management.server.servlet.context-path if management.server.port is configured. */ private String basePath = "/actuator"; - /** - * Endpoint IDs that should be exposed or '*' for all. - */ - private Set expose = new LinkedHashSet<>(); - - /** - * Endpoint IDs that should be excluded. - */ - private Set exclude = new LinkedHashSet<>(); - /** * Mapping between endpoint IDs and the path that should expose them. */ private final Map pathMapping = new LinkedHashMap<>(); + public Exposure getExposure() { + return this.exposure; + } + public String getBasePath() { return this.basePath; } @@ -70,24 +66,39 @@ public class WebEndpointProperties { return basePath; } - public Set getExpose() { - return this.expose; - } - - public void setExpose(Set expose) { - this.expose = expose; - } - - public Set getExclude() { - return this.exclude; - } - - public void setExclude(Set exclude) { - this.exclude = exclude; - } - public Map getPathMapping() { return this.pathMapping; } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 4e639fba7b..79c5bc529f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -28,11 +28,11 @@ "description": "Whether to enable or disable all endpoints by default." }, { - "name": "management.endpoints.jmx.expose", + "name": "management.endpoints.jmx.exposure.include", "defaultValue": "*" }, { - "name": "management.endpoints.web.expose", + "name": "management.endpoints.web.exposure.include", "defaultValue": [ "health", "info" @@ -755,7 +755,7 @@ "description": "Whether to enable JMX export of all endpoints.", "defaultValue": true, "deprecation": { - "replacement": "management.endpoints.jmx.exclude", + "replacement": "management.endpoints.jmx.exposure.exclude", "level": "error" } }, diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java index 0f6a19507e..ebca3bd93d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java @@ -56,7 +56,7 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWit * @author Andy Wilkinson */ @TestPropertySource(properties = { "spring.jackson.serialization.indent_output=true", - "management.endpoints.web.expose=*", + "management.endpoints.web.exposure.include=*", "spring.jackson.default-property-inclusion=non_null" }) public class AbstractEndpointDocumentationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java index 6e95ac2e16..68fe1254a3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java @@ -61,7 +61,8 @@ public class ControllerEndpointWebFluxIntegrationTests { new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); this.context = new AnnotationConfigReactiveWebApplicationContext(); this.context.register(DefaultConfiguration.class, ExampleController.class); - TestPropertyValues.of("management.endpoints.web.expose=*").applyTo(this.context); + TestPropertyValues.of("management.endpoints.web.exposure.include=*").applyTo( + this.context); this.context.refresh(); WebTestClient webClient = WebTestClient.bindToApplicationContext(this.context) .build(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java index 3bef93bc07..ad73751929 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java @@ -84,7 +84,7 @@ public class ControllerEndpointWebMvcIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class, ExampleController.class); TestPropertyValues.of("management.endpoints.web.base-path:/management", - "management.endpoints.web.expose=*").applyTo(this.context); + "management.endpoints.web.exposure.include=*").applyTo(this.context); MockMvc mockMvc = createSecureMockMvc(); mockMvc.perform(get("/management/example")).andExpect(status().isOk()); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java index 5bfd7c7060..ce6f991d7c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java @@ -55,7 +55,7 @@ public class JerseyEndpointIntegrationTests { ManagementContextAutoConfiguration.class, BeansEndpointAutoConfiguration.class)) .withUserConfiguration(EndpointsConfiguration.class) - .withPropertyValues("management.endpoints.web.expose:*", + .withPropertyValues("management.endpoints.web.exposure.include:*", "server.port:0") .run((context) -> { int port = context.getSourceApplicationContext( diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java index bd589c9c79..5fa24d3dbf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java @@ -64,7 +64,8 @@ public class JmxEndpointIntegrationTests { @Test public void jmxEndpointsCanBeExcluded() { - this.contextRunner.withPropertyValues("management.endpoints.jmx.exclude:*") + this.contextRunner + .withPropertyValues("management.endpoints.jmx.exposure.exclude:*") .run((context) -> { MBeanServer mBeanServer = context.getBean(MBeanServer.class); checkEndpointMBeans(mBeanServer, new String[0], @@ -77,7 +78,8 @@ public class JmxEndpointIntegrationTests { @Test public void singleJmxEndpointCanBeExposed() { - this.contextRunner.withPropertyValues("management.endpoints.jmx.expose=beans") + this.contextRunner + .withPropertyValues("management.endpoints.jmx.exposure.include=beans") .run((context) -> { MBeanServer mBeanServer = context.getBean(MBeanServer.class); checkEndpointMBeans(mBeanServer, new String[] { "beans" }, diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java index 4e476afc78..4541408511 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java @@ -61,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext -@TestPropertySource(properties = "management.endpoints.web.expose=jolokia") +@TestPropertySource(properties = "management.endpoints.web.exposure.include=jolokia") public class JolokiaEndpointAutoConfigurationIntegrationTests { @Autowired diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointCorsIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointCorsIntegrationTests.java index 34a43343ce..99ccc66ed2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointCorsIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointCorsIntegrationTests.java @@ -54,7 +54,8 @@ public class WebFluxEndpointCorsIntegrationTests { ManagementContextAutoConfiguration.class, ReactiveManagementContextAutoConfiguration.class, BeansEndpointAutoConfiguration.class); - TestPropertyValues.of("management.endpoints.web.expose:*").applyTo(this.context); + TestPropertyValues.of("management.endpoints.web.exposure.include:*").applyTo( + this.context); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointIntegrationTests.java index 254032951b..f4b211c421 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointIntegrationTests.java @@ -55,7 +55,7 @@ public class WebFluxEndpointIntegrationTests { ReactiveManagementContextAutoConfiguration.class, BeansEndpointAutoConfiguration.class)) .withUserConfiguration(EndpointsConfiguration.class) - .withPropertyValues("management.endpoints.web.expose:*") + .withPropertyValues("management.endpoints.web.exposure.include:*") .run((context) -> { WebTestClient client = createWebTestClient(context); client.get().uri("/actuator").exchange().expectStatus().isOk() diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointCorsIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointCorsIntegrationTests.java index 8b2cbfec01..aed3952064 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointCorsIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointCorsIntegrationTests.java @@ -62,7 +62,8 @@ public class WebMvcEndpointCorsIntegrationTests { ManagementContextAutoConfiguration.class, ServletManagementContextAutoConfiguration.class, BeansEndpointAutoConfiguration.class); - TestPropertyValues.of("management.endpoints.web.expose:*").applyTo(this.context); + TestPropertyValues.of("management.endpoints.web.exposure.include:*").applyTo( + this.context); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java index bf0775ad20..27788c8ad1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java @@ -102,7 +102,7 @@ public class WebMvcEndpointExposureIntegrationTests { @Test public void webEndpointsCanBeExposed() { WebApplicationContextRunner contextRunner = this.contextRunner - .withPropertyValues("management.endpoints.web.expose=*"); + .withPropertyValues("management.endpoints.web.exposure.include=*"); contextRunner.run((context) -> { WebTestClient client = createClient(context); assertThat(isExposed(client, HttpMethod.GET, "beans")).isTrue(); @@ -123,7 +123,7 @@ public class WebMvcEndpointExposureIntegrationTests { @Test public void singleWebEndpointCanBeExposed() { WebApplicationContextRunner contextRunner = this.contextRunner - .withPropertyValues("management.endpoints.web.expose=beans"); + .withPropertyValues("management.endpoints.web.exposure.include=beans"); contextRunner.run((context) -> { WebTestClient client = createClient(context); assertThat(isExposed(client, HttpMethod.GET, "beans")).isTrue(); @@ -144,8 +144,8 @@ public class WebMvcEndpointExposureIntegrationTests { @Test public void singleWebEndpointCanBeExcluded() { WebApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues( - "management.endpoints.web.expose=*", - "management.endpoints.web.exclude=shutdown"); + "management.endpoints.web.exposure.include=*", + "management.endpoints.web.exposure.exclude=shutdown"); contextRunner.run((context) -> { WebTestClient client = createClient(context); assertThat(isExposed(client, HttpMethod.GET, "beans")).isTrue(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java index b8bdf6547b..ea9ee4fa0a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java @@ -105,7 +105,7 @@ public class WebMvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); TestPropertyValues.of("management.endpoints.web.base-path:/management", - "management.endpoints.web.expose=*").applyTo(this.context); + "management.endpoints.web.exposure.include=*").applyTo(this.context); MockMvc mockMvc = createSecureMockMvc(); mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); } @@ -114,7 +114,8 @@ public class WebMvcEndpointIntegrationTests { public void linksAreProvidedToAllEndpointTypes() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(DefaultConfiguration.class, EndpointsConfiguration.class); - TestPropertyValues.of("management.endpoints.web.expose=*").applyTo(this.context); + TestPropertyValues.of("management.endpoints.web.exposure.include=*").applyTo( + this.context); MockMvc mockMvc = doCreateMockMvc(); mockMvc.perform(get("/actuator").accept("*/*")).andExpect(status().isOk()) .andExpect(jsonPath("_links", both(hasKey("beans")).and(hasKey("servlet")) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java index 1cf4b4d56b..8175757513 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class HeapDumpWebEndpointAutoConfigurationTests { private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withPropertyValues("management.endpoints.web.expose:*") + .withPropertyValues("management.endpoints.web.exposure.include:*") .withUserConfiguration(HeapDumpWebEndpointAutoConfiguration.class); @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java index e1e84ccaae..631383653f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java @@ -42,7 +42,8 @@ import org.springframework.test.web.reactive.server.WebTestClient; * {@link org.springframework.core.env.Environment} are reset at the end of every test. * This means that {@link TestPropertyValues} can be used in a test without affecting the * {@code Environment} of other tests in the same class. The runner always sets the flag - * {@code management.endpoints.web.expose} to {@code *} so that web endpoints are enabled. + * {@code management.endpoints.web.exposure.include} to {@code *} so that web endpoints + * are enabled. * * @author Andy Wilkinson * @author Phillip Webb diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 139158f17b..e35d6bc2e9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1151,15 +1151,15 @@ content into your application. Rather, pick only the properties that you need. management.endpoints.enabled-by-default= # Enable or disable all endpoints by default. # ENDPOINTS JMX CONFIGURATION ({sc-spring-boot-actuator-autoconfigure}/endpoint/jmx/JmxEndpointProperties.{sc-ext}[JmxEndpointProperties]) - management.endpoints.jmx.expose=* # Endpoint IDs that should be exposed or '*' for all. - management.endpoints.jmx.exclude= # Endpoint IDs that should be excluded. management.endpoints.jmx.domain=org.springframework.boot # Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set. + management.endpoints.jmx.exposure.include=* # Endpoint IDs that should be included or '*' for all. + management.endpoints.jmx.exposure.exclude= # Endpoint IDs that should be excluded. management.endpoints.jmx.static-names=false # Additional static properties to append to all ObjectNames of MBeans representing Endpoints. management.endpoints.jmx.unique-names=false # Whether to ensure that ObjectNames are modified in case of conflict. # ENDPOINTS WEB CONFIGURATION ({sc-spring-boot-actuator-autoconfigure}/endpoint/web/WebEndpointProperties.{sc-ext}[WebEndpointProperties]) - management.endpoints.web.expose=info,health # Endpoint IDs that should be exposed or '*' for all. - management.endpoints.web.exclude= # Endpoint IDs that should be excluded. + management.endpoints.web.exposure.include=info,health # Endpoint IDs that should be included or '*' for all. + management.endpoints.web.exposure.exclude= # Endpoint IDs that should be excluded. management.endpoints.web.base-path=/actuator # Base path for Web endpoints. Relative to server.servlet.context-path or management.server.servlet.context-path if management.server.port is configured. management.endpoints.web.path-mapping= # Mapping between endpoint IDs and the path that should expose them. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 82f7623b28..ff308d2933 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -197,7 +197,7 @@ disables all other endpoints: NOTE: Disabled endpoints are removed entirely from the application context. If you want to change only the technologies over which an endpoint is exposed, use the -<> +<> instead. @@ -298,38 +298,38 @@ endpoints: |=== -To change which endpoints are exposed, use the following technology-specific `expose` and +To change which endpoints are exposed, use the following technology-specific `include` and `exclude` properties: [cols="3,1"] |=== |Property | Default -|`management.endpoints.jmx.exclude` +|`management.endpoints.jmx.exposure.exclude` | -|`management.endpoints.jmx.expose` +|`management.endpoints.jmx.exposure.include` | `*` -|`management.endpoints.web.exclude` +|`management.endpoints.web.exposure.exclude` | -|`management.endpoints.web.expose` +|`management.endpoints.web.exposure.include` | `info, health` |=== -The `expose` property lists the IDs of the endpoints that are exposed. The `exclude` +The `include` property lists the IDs of the endpoints that are exposed. The `exclude` property lists the IDs of the endpoints that should not be exposed. The `exclude` -property takes precedence over the `expose` property. Both `expose` and `exclude` properties -can be configured with a list of endpoint IDs. +property takes precedence over the `include` property. Both `include` and `exclude` +properties can be configured with a list of endpoint IDs. -For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` -endpoints, use the following property: +For example, to stop exposing all endpoints over JMX and only expose the `health` and +`info` endpoints, use the following property: [source,properties,indent=0] ---- - management.endpoints.jmx.expose=health,info + management.endpoints.jmx.exposure.include=health,info ---- `*` can be used to select all endpoints. For example, to expose everything over HTTP @@ -337,8 +337,8 @@ except the `env` and `beans` endpoints, use the following properties: [source,properties,indent=0] ---- - management.endpoints.web.expose=* - management.endpoints.web.exclude=env,beans + management.endpoints.web.exposure.include=* + management.endpoints.web.exposure.exclude=env,beans ---- NOTE: If your application is exposed publicly, we strongly recommend that you also @@ -384,12 +384,12 @@ methods are also available on `EndpointRequest`. See the API documentation If you deploy applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do so by changing the -`management.endpoints.web.expose` property, as follows: +`management.endpoints.web.exposure.include` property, as follows: .application.properties [source,properties,indent=0] ---- - management.endpoints.web.expose=* + management.endpoints.web.exposure.include=* ---- Additionally, if Spring Security is present, you would need to add custom security @@ -1014,11 +1014,12 @@ settings show an example of doing so in `application.properties`: [[production-ready-disable-jmx-endpoints]] === Disabling JMX Endpoints If you do not want to expose endpoints over JMX, you can set the -`management.endpoints.jmx.exclude` property to `*`, as shown in the following example: +`management.endpoints.jmx.exposure.exclude` property to `*`, as shown in the following +example: [source,properties,indent=0] ---- - management.endpoints.jmx.exclude=* + management.endpoints.jmx.exposure.exclude=* ---- @@ -1038,7 +1039,7 @@ Maven, you would add the following dependency: ---- The Jolokia endpoint can then be exposed by adding `jolokia` or `*` to the -`management.endpoints.web.expose` property. You can then access it by using +`management.endpoints.web.exposure.include` property. You can then access it by using `/actuator/jolokia` on your management HTTP server. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 55553ed100..4a30de2b4c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3131,15 +3131,18 @@ In other words, the two configurations in the following example use the Google p [[boot-features-security-actuator]] === Actuator Security -For security purposes, all actuators other than `/health` and `/info` are disabled by default. -The `management.endpoints.web.expose` flag can be used to enable the actuators. -If Spring Security is on the classpath and no other WebSecurityConfigurerAdapter is present, -the actuators are secured by Spring Boot auto-config. If you define a custom `WebSecurityConfigurerAdapter`, -Spring Boot auto-config will back off and you will be in full control of actuator access rules. +For security purposes, all actuators other than `/health` and `/info` are disabled by +default. The `management.endpoints.web.exposure.include` property can be used to enable +the actuators. -NOTE: Before setting the `management.endpoints.web.expose`, ensure that the exposed actuators -do not contain sensitive information and/or are secured by placing them behind a firewall or by -something like Spring Security. +If Spring Security is on the classpath and no other WebSecurityConfigurerAdapter is +present, the actuators are secured by Spring Boot auto-config. If you define a custom +`WebSecurityConfigurerAdapter`, Spring Boot auto-config will back off and you will be in +full control of actuator access rules. + +NOTE: Before setting the `management.endpoints.web.exposure.include`, ensure that the +exposed actuators do not contain sensitive information and/or are secured by placing them +behind a firewall or by something like Spring Security. diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/application.properties index de81b0e65d..db3cdb647b 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/application.properties @@ -1,2 +1,2 @@ -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* management.endpoint.health.show-details=always diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/resources/application.properties index 3e49778b36..2583f7fcef 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/resources/application.properties @@ -1,4 +1,4 @@ spring.security.user.name=user spring.security.user.password=password management.endpoint.shutdown.enabled=true -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/application.properties index 4abde8d87b..011eb692af 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/application.properties @@ -1,4 +1,4 @@ spring.security.user.name=user spring.security.user.password=password management.health.diskspace.enabled=false -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties index eee0620b13..dd88f70938 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties @@ -7,7 +7,7 @@ spring.security.user.password=password # logging.level.org.springframework.security=DEBUG management.server.address=127.0.0.1 -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* management.endpoint.shutdown.enabled=true server.tomcat.basedir=target/tomcat diff --git a/spring-boot-samples/spring-boot-sample-cache/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-cache/src/main/resources/application.properties index da7c308b54..e6f1571122 100644 --- a/spring-boot-samples/spring-boot-sample-cache/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-cache/src/main/resources/application.properties @@ -1,4 +1,4 @@ -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* # # Infinispan configuration file location. diff --git a/spring-boot-samples/spring-boot-sample-flyway/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-flyway/src/main/resources/application.properties index 4a37736a68..fb15113cbf 100644 --- a/spring-boot-samples/spring-boot-sample-flyway/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-flyway/src/main/resources/application.properties @@ -1,4 +1,4 @@ -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* spring.jpa.hibernate.ddl-auto=validate spring.jpa.open-in-view=true spring.h2.console.enabled=true diff --git a/spring-boot-samples/spring-boot-sample-liquibase/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-liquibase/src/main/resources/application.properties index 52bced69c6..a42d244c89 100644 --- a/spring-boot-samples/spring-boot-sample-liquibase/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-liquibase/src/main/resources/application.properties @@ -1,3 +1,3 @@ -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* spring.h2.console.enabled=true diff --git a/spring-boot-samples/spring-boot-sample-secure-webflux/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-secure-webflux/src/main/resources/application.properties index 093ae1eb74..c5268e4066 100644 --- a/spring-boot-samples/spring-boot-sample-secure-webflux/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-secure-webflux/src/main/resources/application.properties @@ -1,3 +1,3 @@ spring.security.user.name=user spring.security.user.password=password -management.endpoints.web.expose=* \ No newline at end of file +management.endpoints.web.exposure.include=* \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-session/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-session/src/main/resources/application.properties index 52c833b58e..488b0d5579 100644 --- a/spring-boot-samples/spring-boot-sample-session/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-session/src/main/resources/application.properties @@ -1,3 +1,3 @@ spring.security.user.name=user spring.security.user.password=password -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=* diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/resources/application.properties index 3d580fcd11..f5a3d0f72c 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/resources/application.properties @@ -1,3 +1,3 @@ spring.thymeleaf.cache: false logging.level.org.springframework.security: INFO -management.endpoints.web.expose=* +management.endpoints.web.exposure.include=*