|
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.extension.ExtendWith
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
|
import org.springframework.context.annotation.Bean
|
|
|
import org.springframework.context.annotation.Configuration
|
|
|
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
|
|
|
import org.springframework.security.config.test.SpringTestContext
|
|
@@ -69,6 +70,16 @@ class WebAuthnDslTests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ fun `explicit HttpMessageConverter`() {
|
|
|
+ this.spring.register(ExplicitHttpMessageConverterConfig::class.java).autowire()
|
|
|
+
|
|
|
+ this.mockMvc.post("/test1")
|
|
|
+ .andExpect {
|
|
|
+ status { isForbidden() }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
fun `webauthn and formLogin configured with default registration page`() {
|
|
|
spring.register(DefaultWebauthnConfig::class.java).autowire()
|
|
@@ -166,6 +177,33 @@ class WebAuthnDslTests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Configuration
|
|
|
+ @EnableWebSecurity
|
|
|
+ open class ExplicitHttpMessageConverterConfig {
|
|
|
+ @Bean
|
|
|
+ open fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
|
|
+ http {
|
|
|
+ webAuthn {
|
|
|
+ rpName = "Spring Security Relying Party"
|
|
|
+ rpId = "example.com"
|
|
|
+ allowedOrigins = setOf("https://example.com")
|
|
|
+ messageConverter = MappingJackson2HttpMessageConverter()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return http.build()
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ open fun userDetailsService(): UserDetailsService {
|
|
|
+ val userDetails = User.withDefaultPasswordEncoder()
|
|
|
+ .username("rod")
|
|
|
+ .password("password")
|
|
|
+ .roles("USER")
|
|
|
+ .build()
|
|
|
+ return InMemoryUserDetailsManager(userDetails)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Configuration
|
|
|
@EnableWebSecurity
|
|
|
open class WebauthnConfig {
|