mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Make the Spring Security part of CF autoconfig conditional
Otherwise you get a class not found exception at runtime in CF when Spring Securtity is not on the classpath.
This commit is contained in:
parent
cc8ecb6ff5
commit
1baf3c63c4
Notes:
Phillip Webb
2016-12-20 10:58:09 -08:00
Fixes gh-7622
@ -26,6 +26,7 @@ import org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.security.IgnoredRequestCustomizer;
|
||||
@ -98,18 +99,27 @@ public class CloudFoundryActuatorAutoConfiguration {
|
||||
return corsConfiguration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IgnoredRequestCustomizer cloudFoundryIgnoredRequestCustomizer() {
|
||||
return new CloudFoundryIgnoredRequestCustomizer();
|
||||
}
|
||||
/**
|
||||
* Nested configuration for ignored requests if Spring Security is present.
|
||||
*
|
||||
*/
|
||||
@ConditionalOnClass(WebSecurity.class)
|
||||
static class CloudFoundryIgnoredRequestConfiguration {
|
||||
|
||||
private class CloudFoundryIgnoredRequestCustomizer
|
||||
implements IgnoredRequestCustomizer {
|
||||
@Bean
|
||||
public IgnoredRequestCustomizer cloudFoundryIgnoredRequestCustomizer() {
|
||||
return new CloudFoundryIgnoredRequestCustomizer();
|
||||
}
|
||||
|
||||
private static class CloudFoundryIgnoredRequestCustomizer
|
||||
implements IgnoredRequestCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(WebSecurity.IgnoredRequestConfigurer configurer) {
|
||||
configurer.requestMatchers(
|
||||
new AntPathRequestMatcher("/cloudfoundryapplication/**"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(WebSecurity.IgnoredRequestConfigurer configurer) {
|
||||
configurer.requestMatchers(
|
||||
new AntPathRequestMatcher("/cloudfoundryapplication/**"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user