@@ -36,25 +36,36 @@ public class WebSecurityConfig {
3636
3737 @Bean
3838 public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
39+
40+ http.authenticationManager(authenticationManager);
3941 // WebAuthn Login
40- http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
41- .loginPage("/login")
42- .usernameParameter("username")
43- .passwordParameter("rawPassword")
44- .credentialIdParameter("credentialId")
45- .clientDataJSONParameter("clientDataJSON")
46- .authenticatorDataParameter("authenticatorData")
47- .signatureParameter("signature")
48- .clientExtensionsJSONParameter("clientExtensionsJSON")
49- .loginProcessingUrl("/login")
50- .rpId("example.com")
51- .attestationOptionsEndpoint()
52- .attestationOptionsProvider(attestationOptionsProvider)
53- .and()
54- .assertionOptionsEndpoint()
55- .assertionOptionsProvider(assertionOptionsProvider)
56- .and()
57- .authenticationManager(authenticationManager);
42+ http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
43+ customizer
44+ .loginPage("/login")
45+ .usernameParameter("username")
46+ .passwordParameter("password")
47+ .credentialIdParameter("credentialId")
48+ .clientDataJSONParameter("clientDataJSON")
49+ .authenticatorDataParameter("authenticatorData")
50+ .signatureParameter("signature")
51+ .clientExtensionsJSONParameter("clientExtensionsJSON")
52+ .loginProcessingUrl("/login")
53+ .attestationOptionsEndpoint()
54+ .rp()
55+ .name("WebAuthn4J Spring Security Sample")
56+ .and()
57+ .pubKeyCredParams(
58+ new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS256), // Windows Hello
59+ new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256) // FIDO U2F Key, etc
60+ )
61+ .extensions()
62+ .credProps(true)
63+ .and()
64+ .assertionOptionsEndpoint()
65+ .and()
66+ .successHandler(authenticationSuccessHandler)
67+ .failureHandler(authenticationFailureHandler);
68+ });
5869 }
5970}
6071----
@@ -144,8 +155,10 @@ public class WebSecurityConfig {
144155
145156 @Bean
146157 public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
158+ http.authenticationManager(authenticationManager);
147159 // WebAuthn Login
148- http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
160+ http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
161+ customizer
149162 .rpId("example.com")
150163 .attestationOptionsEndpoint()
151164 .attestationOptionsProvider(attestationOptionsProvider)
@@ -172,8 +185,8 @@ public class WebSecurityConfig {
172185 .processingUrl("/webauthn/assertion/options")
173186 .rpId("example.com")
174187 .userVerification(UserVerificationRequirement.PREFERRED)
175- .and()
176- .authenticationManager(authenticationManager );
188+ .and();
189+ } );
177190 }
178191}
179192
@@ -192,13 +205,16 @@ public class WebSecurityConfig {
192205
193206 @Bean
194207 public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
208+
195209 // WebAuthn Login
196- http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
210+ http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
211+ customizer
197212 .attestationOptionsEndpoint()
198213 .attestationOptionsProvider(attestationOptionsProvider)
199214 .processingUrl("/webauthn/attestation/options")
200215 .processingUrl("/webauthn/attestation/options")
201- .user(new MyPublicKeyCredentialUserEntityProvider()) // put your PublicKeyCredentialUserEntityProvider implementation
216+ .user(new MyPublicKeyCredentialUserEntityProvider()); // put your PublicKeyCredentialUserEntityProvider implementation
217+ });
202218 }
203219}
204220----
0 commit comments