|
16 | 16 |
|
17 | 17 | package org.springframework.boot.security.autoconfigure.servlet;
|
18 | 18 |
|
19 |
| -import org.springframework.beans.BeansException; |
20 |
| -import org.springframework.beans.factory.ObjectProvider; |
21 |
| -import org.springframework.beans.factory.config.BeanPostProcessor; |
22 | 19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
23 | 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
24 | 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
@@ -53,23 +50,12 @@ class SpringBootWebSecurityConfiguration {
|
53 | 50 | static class PathPatternRequestMatcherBuilderConfiguration {
|
54 | 51 |
|
55 | 52 | @Bean
|
56 |
| - static BeanPostProcessor pathPatternRequestMatcherBuilderBasePathCustomizer( |
57 |
| - ObjectProvider<DispatcherServletPath> dispatcherServletPath) { |
58 |
| - return new BeanPostProcessor() { |
59 |
| - |
60 |
| - @Override |
61 |
| - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
62 |
| - if ("pathPatternRequestMatcherBuilder".equals(beanName) |
63 |
| - && bean instanceof PathPatternRequestMatcher.Builder builder) { |
64 |
| - String path = dispatcherServletPath.getObject().getPath(); |
65 |
| - if (!path.equals("/")) { |
66 |
| - return builder.basePath(path); |
67 |
| - } |
68 |
| - } |
69 |
| - return bean; |
70 |
| - } |
71 |
| - |
72 |
| - }; |
| 53 | + @ConditionalOnMissingBean |
| 54 | + PathPatternRequestMatcher.Builder pathPatternRequestMatcherBuilder( |
| 55 | + DispatcherServletPath dispatcherServletPath) { |
| 56 | + PathPatternRequestMatcher.Builder builder = PathPatternRequestMatcher.withDefaults(); |
| 57 | + String path = dispatcherServletPath.getPath(); |
| 58 | + return (!path.equals("/")) ? builder.basePath(path) : builder; |
73 | 59 | }
|
74 | 60 |
|
75 | 61 | }
|
|
0 commit comments