mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Adapt to latest changes in Spring Security snapshots
See https://github.com/spring-projects/spring-security/issues/17746
This commit is contained in:
+6
-20
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.boot.security.autoconfigure.servlet;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -53,23 +50,12 @@ class SpringBootWebSecurityConfiguration {
|
||||
static class PathPatternRequestMatcherBuilderConfiguration {
|
||||
|
||||
@Bean
|
||||
static BeanPostProcessor pathPatternRequestMatcherBuilderBasePathCustomizer(
|
||||
ObjectProvider<DispatcherServletPath> dispatcherServletPath) {
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if ("pathPatternRequestMatcherBuilder".equals(beanName)
|
||||
&& bean instanceof PathPatternRequestMatcher.Builder builder) {
|
||||
String path = dispatcherServletPath.getObject().getPath();
|
||||
if (!path.equals("/")) {
|
||||
return builder.basePath(path);
|
||||
}
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
};
|
||||
@ConditionalOnMissingBean
|
||||
PathPatternRequestMatcher.Builder pathPatternRequestMatcherBuilder(
|
||||
DispatcherServletPath dispatcherServletPath) {
|
||||
PathPatternRequestMatcher.Builder builder = PathPatternRequestMatcher.withDefaults();
|
||||
String path = dispatcherServletPath.getPath();
|
||||
return (!path.equals("/")) ? builder.basePath(path) : builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ class SecurityAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenACustomPathPatternRequestMatcherBuilderwhenDispatcherServletPathIsSetBuilderBasePathIsNotCustomized() {
|
||||
void givenACustomPathPatternRequestMatcherBuilderWhenDispatcherServletPathIsSetBuilderBasePathIsNotCustomized() {
|
||||
this.contextRunner.withBean(PathPatternRequestMatcherBuilderFactoryBean.class)
|
||||
.withBean(DispatcherServletPath.class, () -> () -> "/dispatcher-servlet")
|
||||
.run((context) -> {
|
||||
|
||||
Reference in New Issue
Block a user