File tree 2 files changed +39
-0
lines changed
main/kotlin/org/springframework/security/config/annotation/web
test/kotlin/org/springframework/security/config/annotation/web
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import org.springframework.security.config.annotation.web.configurers.WebAuthnCo
24
24
* @property rpName the relying party name
25
25
* @property rpId the relying party id
26
26
* @property the allowed origins
27
+ * @property disableDefaultRegistrationPage disable default webauthn registration page
27
28
* @since 6.4
28
29
* @author Rob Winch
29
30
* @author Max Batischev
@@ -33,12 +34,14 @@ class WebAuthnDsl {
33
34
var rpName: String? = null
34
35
var rpId: String? = null
35
36
var allowedOrigins: Set <String >? = null
37
+ var disableDefaultRegistrationPage: Boolean? = false
36
38
37
39
internal fun get (): (WebAuthnConfigurer <HttpSecurity >) -> Unit {
38
40
return { webAuthn ->
39
41
rpName?.also { webAuthn.rpName(rpName) }
40
42
rpId?.also { webAuthn.rpId(rpId) }
41
43
allowedOrigins?.also { webAuthn.allowedOrigins(allowedOrigins) }
44
+ disableDefaultRegistrationPage?.also { webAuthn.disableDefaultRegistrationPage(disableDefaultRegistrationPage!! ) }
42
45
}
43
46
}
44
47
}
Original file line number Diff line number Diff line change @@ -74,6 +74,42 @@ class WebAuthnDslTests {
74
74
}
75
75
}
76
76
77
+ @Test
78
+ fun `webauthn and formLogin configured with disabled default registration page` () {
79
+ spring.register(FormLoginAndNoDefaultRegistrationPageConfiguration ::class .java).autowire()
80
+
81
+ this .mockMvc.get(" /login/webauthn.js" )
82
+ .andExpect {
83
+ MockMvcResultMatchers .status().isOk
84
+ header {
85
+ string(" content-type" , " text/javascript;charset=UTF-8" )
86
+ }
87
+ content {
88
+ string(Matchers .containsString(" async function authenticate(" ))
89
+ }
90
+ }
91
+ }
92
+
93
+ @Configuration
94
+ @EnableWebSecurity
95
+ open class FormLoginAndNoDefaultRegistrationPageConfiguration {
96
+ @Bean
97
+ open fun userDetailsService (): UserDetailsService =
98
+ InMemoryUserDetailsManager ()
99
+
100
+
101
+ @Bean
102
+ open fun securityFilterChain (http : HttpSecurity ): SecurityFilterChain {
103
+ http{
104
+ formLogin { }
105
+ webAuthn {
106
+ disableDefaultRegistrationPage = true
107
+ }
108
+ }
109
+ return http.build()
110
+ }
111
+ }
112
+
77
113
@Configuration
78
114
@EnableWebSecurity
79
115
open class DefaultWebauthnConfig {
You can’t perform that action at this time.
0 commit comments