File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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
2424 * @property rpName the relying party name
2525 * @property rpId the relying party id
2626 * @property the allowed origins
27+ * @property disableDefaultRegistrationPage disable default webauthn registration page
2728 * @since 6.4
2829 * @author Rob Winch
2930 * @author Max Batischev
@@ -33,12 +34,14 @@ class WebAuthnDsl {
3334 var rpName: String? = null
3435 var rpId: String? = null
3536 var allowedOrigins: Set <String >? = null
37+ var disableDefaultRegistrationPage: Boolean? = false
3638
3739 internal fun get (): (WebAuthnConfigurer <HttpSecurity >) -> Unit {
3840 return { webAuthn ->
3941 rpName?.also { webAuthn.rpName(rpName) }
4042 rpId?.also { webAuthn.rpId(rpId) }
4143 allowedOrigins?.also { webAuthn.allowedOrigins(allowedOrigins) }
44+ disableDefaultRegistrationPage?.also { webAuthn.disableDefaultRegistrationPage(disableDefaultRegistrationPage!! ) }
4245 }
4346 }
4447}
Original file line number Diff line number Diff line change @@ -74,6 +74,42 @@ class WebAuthnDslTests {
7474 }
7575 }
7676
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+
77113 @Configuration
78114 @EnableWebSecurity
79115 open class DefaultWebauthnConfig {
You can’t perform that action at this time.
0 commit comments