@@ -22,6 +22,7 @@ import org.junit.jupiter.api.extension.ExtendWith
22
22
import org.springframework.beans.factory.annotation.Autowired
23
23
import org.springframework.context.annotation.Bean
24
24
import org.springframework.context.annotation.Configuration
25
+ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
25
26
import org.springframework.security.config.annotation.web.builders.HttpSecurity
26
27
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
27
28
import org.springframework.security.config.test.SpringTestContext
@@ -69,6 +70,16 @@ class WebAuthnDslTests {
69
70
}
70
71
}
71
72
73
+ @Test
74
+ fun `explicit HttpMessageConverter` () {
75
+ this .spring.register(ExplicitHttpMessageConverterConfig ::class .java).autowire()
76
+
77
+ this .mockMvc.post(" /test1" )
78
+ .andExpect {
79
+ status { isForbidden() }
80
+ }
81
+ }
82
+
72
83
@Test
73
84
fun `webauthn and formLogin configured with default registration page` () {
74
85
spring.register(DefaultWebauthnConfig ::class .java).autowire()
@@ -166,6 +177,33 @@ class WebAuthnDslTests {
166
177
}
167
178
}
168
179
180
+ @Configuration
181
+ @EnableWebSecurity
182
+ open class ExplicitHttpMessageConverterConfig {
183
+ @Bean
184
+ open fun securityFilterChain (http : HttpSecurity ): SecurityFilterChain {
185
+ http {
186
+ webAuthn {
187
+ rpName = " Spring Security Relying Party"
188
+ rpId = " example.com"
189
+ allowedOrigins = setOf (" https://example.com" )
190
+ messageConverter = MappingJackson2HttpMessageConverter ()
191
+ }
192
+ }
193
+ return http.build()
194
+ }
195
+
196
+ @Bean
197
+ open fun userDetailsService (): UserDetailsService {
198
+ val userDetails = User .withDefaultPasswordEncoder()
199
+ .username(" rod" )
200
+ .password(" password" )
201
+ .roles(" USER" )
202
+ .build()
203
+ return InMemoryUserDetailsManager (userDetails)
204
+ }
205
+ }
206
+
169
207
@Configuration
170
208
@EnableWebSecurity
171
209
open class WebauthnConfig {
0 commit comments