This commit is contained in:
Andy Wilkinson
2017-10-17 15:41:46 +01:00
parent 70f6c784c7
commit 688da652ac
26 changed files with 244 additions and 225 deletions

View File

@@ -38,9 +38,7 @@ public class WebEndpointProperties {
}
public void setBasePath(String basePath) {
this.basePath = basePath;
this.basePath = basePath;
}
}

View File

@@ -57,12 +57,12 @@ public class WebMvcEndpointManagementContextConfiguration {
@ConditionalOnMissingBean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(
EndpointProvider<WebEndpointOperation> provider,
EndpointMediaTypes endpointMediaTypes,
CorsEndpointProperties corsProperties,
EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties,
WebEndpointProperties webEndpointProperties) {
WebMvcEndpointHandlerMapping handlerMapping = new WebMvcEndpointHandlerMapping(
new EndpointMapping(webEndpointProperties.getBasePath()),
provider.getEndpoints(), endpointMediaTypes, getCorsConfiguration(corsProperties));
provider.getEndpoints(), endpointMediaTypes,
getCorsConfiguration(corsProperties));
return handlerMapping;
}

View File

@@ -43,17 +43,18 @@ import org.springframework.web.context.ConfigurableWebApplicationContext;
/**
* {@link EnableAutoConfiguration Auto-configuration} for the management context. If the
* {@code management.server.port} is the same as the {@code server.port} the management context
* will be the same as the main application context. If the {@code management.server.port} is
* different to the {@code server.port} the management context will be a separate context
* that has the main application context as its parent.
* {@code management.server.port} is the same as the {@code server.port} the management
* context will be the same as the main application context. If the
* {@code management.server.port} is different to the {@code server.port} the management
* context will be a separate context that has the main application context as its parent.
*
* @author Andy Wilkinson
* @since 2.0.0
*/
@Configuration
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
@EnableConfigurationProperties({ WebEndpointProperties.class, ManagementServerProperties.class })
@EnableConfigurationProperties({ WebEndpointProperties.class,
ManagementServerProperties.class })
public class ManagementContextAutoConfiguration {
@Configuration
@@ -77,8 +78,8 @@ public class ManagementContextAutoConfiguration {
}
private void verifySslConfiguration() {
Boolean enabled = this.environment.getProperty("management.server.ssl.enabled",
Boolean.class, false);
Boolean enabled = this.environment
.getProperty("management.server.ssl.enabled", Boolean.class, false);
Assert.state(!enabled,
"Management-specific SSL cannot be configured as the management "
+ "server is not listening on a separate port");

View File

@@ -85,8 +85,7 @@ public class WebMvcEndpointIntegrationTests {
}
@Test
public void endpointsAreSecureWithActuatorRoleWithCustomBasePath()
throws Exception {
public void endpointsAreSecureWithActuatorRoleWithCustomBasePath() throws Exception {
TestSecurityContextHolder.getContext().setAuthentication(
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext();