Disable Jolokia by default

To be consistent with Actuator web endpoints, Jolokia is now disabled
by default.

Closes gh-10090
This commit is contained in:
Stephane Nicoll 2017-08-28 10:18:19 +02:00
parent def094b844
commit da65158eae
6 changed files with 43 additions and 39 deletions

View File

@ -54,7 +54,7 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
@ManagementContextConfiguration @ManagementContextConfiguration
@ConditionalOnWebApplication(type = Type.SERVLET) @ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class }) @ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
@ConditionalOnProperty(value = "management.jolokia.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "management.jolokia.enabled", havingValue = "true")
@EnableConfigurationProperties(JolokiaProperties.class) @EnableConfigurationProperties(JolokiaProperties.class)
public class JolokiaManagementContextConfiguration { public class JolokiaManagementContextConfiguration {

View File

@ -35,7 +35,7 @@ public class JolokiaProperties {
/** /**
* Enable Jolokia. * Enable Jolokia.
*/ */
private boolean enabled = true; private boolean enabled;
/** /**
* Path at which Jolokia will be available. * Path at which Jolokia will be available.

View File

@ -58,7 +58,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext @DirtiesContext
@TestPropertySource(properties = "management.security.enabled=false") @TestPropertySource(properties = { "management.jolokia.enabled=true",
"management.security.enabled=false" })
public class JolokiaManagementContextConfigurationIntegrationTests { public class JolokiaManagementContextConfigurationIntegrationTests {
@Autowired @Autowired

View File

@ -44,7 +44,8 @@ public class JolokiaManagementContextConfigurationTests {
@Test @Test
public void jolokiaIsEnabledByDefault() { public void jolokiaIsEnabledByDefault() {
this.contextRunner.run((context) -> { this.contextRunner.withPropertyValues("management.jolokia.enabled=true")
.run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class); assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);
@ -55,28 +56,29 @@ public class JolokiaManagementContextConfigurationTests {
} }
@Test @Test
public void jolokiaCanBeDisabled() { public void jolokiaIsDisabledByDefault() {
this.contextRunner.withPropertyValues("management.jolokia.enabled=false") this.contextRunner.run((context) -> assertThat(context)
.run((context) -> assertThat(context)
.doesNotHaveBean(ServletRegistrationBean.class)); .doesNotHaveBean(ServletRegistrationBean.class));
} }
@Test @Test
public void customPath() { public void customPath() {
this.contextRunner.withPropertyValues("management.jolokia.path=/lokia") this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
.run(isDefinedOnPath("/application/lokia/*")); "management.jolokia.path=/lokia").run(
isDefinedOnPath("/application/lokia/*"));
} }
@Test @Test
public void customManagementPath() { public void customManagementPath() {
this.contextRunner.withPropertyValues("management.context-path=/admin") this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
.run(isDefinedOnPath("/admin/jolokia/*")); "management.context-path=/admin").run(
isDefinedOnPath("/admin/jolokia/*"));
} }
@Test @Test
public void customInitParameters() { public void customInitParameters() {
this.contextRunner.withPropertyValues("management.jolokia.config.debug=true") this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
.run((context) -> { "management.jolokia.config.debug=true").run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class); assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);

View File

@ -1274,7 +1274,7 @@ content into your application; rather pick only the properties that you need.
# JOLOKIA ({sc-spring-boot-actuator}/autoconfigure/jolokia/JolokiaProperties.{sc-ext}[JolokiaProperties]) # JOLOKIA ({sc-spring-boot-actuator}/autoconfigure/jolokia/JolokiaProperties.{sc-ext}[JolokiaProperties])
management.jolokia.config.*= # Jolokia settings. See the Jolokia manual for details. management.jolokia.config.*= # Jolokia settings. See the Jolokia manual for details.
management.jolokia.enabled=true # Enable Jolokia. management.jolokia.enabled=false # Enable Jolokia.
management.jolokia.path=/jolokia # Path at which Jolokia will be available. management.jolokia.path=/jolokia # Path at which Jolokia will be available.
# TRACING ({sc-spring-boot-actuator}/trace/TraceProperties.{sc-ext}[TraceProperties]) # TRACING ({sc-spring-boot-actuator}/trace/TraceProperties.{sc-ext}[TraceProperties])

View File

@ -1,2 +1,3 @@
health.diskspace.enabled=false health.diskspace.enabled=false
endpoints.all.web.enabled=true endpoints.all.web.enabled=true
management.jolokia.enabled=true