Skip to content

Commit 89f2392

Browse files
committed
Update document to catch up Spring Security 6.0
1 parent 7836bc3 commit 89f2392

File tree

2 files changed

+78
-46
lines changed

2 files changed

+78
-46
lines changed

docs/src/reference/asciidoc/en/configuration.adoc

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
----

docs/src/reference/asciidoc/ja/configuration.adoc

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
----
@@ -149,8 +160,10 @@ public class WebSecurityConfig {
149160
150161
@Bean
151162
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
163+
http.authenticationManager(authenticationManager);
152164
// WebAuthn Login
153-
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
165+
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
166+
customizer
154167
.rpId("example.com")
155168
.attestationOptionsEndpoint()
156169
.attestationOptionsProvider(attestationOptionsProvider)
@@ -177,8 +190,8 @@ public class WebSecurityConfig {
177190
.processingUrl("/webauthn/assertion/options")
178191
.rpId("example.com")
179192
.userVerification(UserVerificationRequirement.PREFERRED)
180-
.and()
181-
.authenticationManager(authenticationManager);
193+
.and();
194+
});
182195
}
183196
}
184197
----
@@ -197,13 +210,16 @@ public class WebSecurityConfig {
197210
198211
@Bean
199212
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
213+
200214
// WebAuthn Login
201-
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
215+
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
216+
customizer
202217
.attestationOptionsEndpoint()
203218
.attestationOptionsProvider(attestationOptionsProvider)
204219
.processingUrl("/webauthn/attestation/options")
205220
.processingUrl("/webauthn/attestation/options")
206-
.user(new MyPublicKeyCredentialUserEntityProvider()) // put your PublicKeyCredentialUserEntityProvider implementation
221+
.user(new MyPublicKeyCredentialUserEntityProvider()); // put your PublicKeyCredentialUserEntityProvider implementation
222+
});
207223
}
208224
}
209225
----

0 commit comments

Comments
 (0)