|
23 | 23 | import org.junit.jupiter.api.extension.ExtendWith; |
24 | 24 |
|
25 | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | +import org.springframework.beans.factory.config.BeanPostProcessor; |
26 | 27 | import org.springframework.context.annotation.Bean; |
27 | 28 | import org.springframework.context.annotation.Configuration; |
28 | 29 | import org.springframework.http.HttpOutputMessage; |
|
42 | 43 | import org.springframework.security.web.authentication.ui.DefaultResourcesFilter; |
43 | 44 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialCreationOptions; |
44 | 45 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialCreationOptions; |
| 46 | +import org.springframework.security.web.webauthn.authentication.WebAuthnAuthenticationFilter; |
45 | 47 | import org.springframework.security.web.webauthn.management.WebAuthnRelyingPartyOperations; |
46 | 48 | import org.springframework.security.web.webauthn.registration.HttpSessionPublicKeyCredentialCreationOptionsRepository; |
47 | 49 | import org.springframework.test.web.servlet.MockMvc; |
@@ -88,6 +90,14 @@ public void webauthnWhenConfiguredConfiguredThenServesCss() throws Exception { |
88 | 90 | .andExpect(content().string(containsString("body {"))); |
89 | 91 | } |
90 | 92 |
|
| 93 | + // gh-18128 |
| 94 | + @Test |
| 95 | + public void webAuthnAuthenticationFilterIsPostProcessed() throws Exception { |
| 96 | + this.spring.register(DefaultWebauthnConfiguration.class, PostProcessorConfiguration.class).autowire(); |
| 97 | + PostProcessorConfiguration postProcess = this.spring.getContext().getBean(PostProcessorConfiguration.class); |
| 98 | + assertThat(postProcess.webauthnFilter).isNotNull(); |
| 99 | + } |
| 100 | + |
91 | 101 | @Test |
92 | 102 | public void webauthnWhenNoFormLoginAndDefaultRegistrationPageConfiguredThenServesJavascript() throws Exception { |
93 | 103 | this.spring.register(NoFormLoginAndDefaultRegistrationPageConfiguration.class).autowire(); |
@@ -289,6 +299,26 @@ SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { |
289 | 299 |
|
290 | 300 | } |
291 | 301 |
|
| 302 | + @Configuration(proxyBeanMethods = false) |
| 303 | + static class PostProcessorConfiguration { |
| 304 | + |
| 305 | + WebAuthnAuthenticationFilter webauthnFilter; |
| 306 | + |
| 307 | + @Bean |
| 308 | + BeanPostProcessor beanPostProcessor() { |
| 309 | + return new BeanPostProcessor() { |
| 310 | + @Override |
| 311 | + public Object postProcessAfterInitialization(Object bean, String beanName) { |
| 312 | + if (bean instanceof WebAuthnAuthenticationFilter filter) { |
| 313 | + PostProcessorConfiguration.this.webauthnFilter = filter; |
| 314 | + } |
| 315 | + return bean; |
| 316 | + } |
| 317 | + }; |
| 318 | + } |
| 319 | + |
| 320 | + } |
| 321 | + |
292 | 322 | @Configuration |
293 | 323 | @EnableWebSecurity |
294 | 324 | static class DefaultWebauthnConfiguration { |
|
0 commit comments