Skip to content

Commit

Permalink
Update document to catch up Spring Security 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ynojima committed Apr 28, 2024
1 parent e06d60a commit dc63853
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 46 deletions.
62 changes: 39 additions & 23 deletions docs/src/reference/asciidoc/en/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,36 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
http.authenticationManager(authenticationManager);
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
.loginPage("/login")
.usernameParameter("username")
.passwordParameter("rawPassword")
.credentialIdParameter("credentialId")
.clientDataJSONParameter("clientDataJSON")
.authenticatorDataParameter("authenticatorData")
.signatureParameter("signature")
.clientExtensionsJSONParameter("clientExtensionsJSON")
.loginProcessingUrl("/login")
.rpId("example.com")
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
.and()
.assertionOptionsEndpoint()
.assertionOptionsProvider(assertionOptionsProvider)
.and()
.authenticationManager(authenticationManager);
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.loginPage("/login")
.usernameParameter("username")
.passwordParameter("password")
.credentialIdParameter("credentialId")
.clientDataJSONParameter("clientDataJSON")
.authenticatorDataParameter("authenticatorData")
.signatureParameter("signature")
.clientExtensionsJSONParameter("clientExtensionsJSON")
.loginProcessingUrl("/login")
.attestationOptionsEndpoint()
.rp()
.name("WebAuthn4J Spring Security Sample")
.and()
.pubKeyCredParams(
new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS256), // Windows Hello
new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256) // FIDO U2F Key, etc
)
.extensions()
.credProps(true)
.and()
.assertionOptionsEndpoint()
.and()
.successHandler(authenticationSuccessHandler)
.failureHandler(authenticationFailureHandler);
});
}
}
----
Expand Down Expand Up @@ -144,8 +155,10 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
http.authenticationManager(authenticationManager);
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.rpId("example.com")
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
Expand All @@ -172,8 +185,8 @@ public class WebSecurityConfig {
.processingUrl("/webauthn/assertion/options")
.rpId("example.com")
.userVerification(UserVerificationRequirement.PREFERRED)
.and()
.authenticationManager(authenticationManager);
.and();
});
}
}
Expand All @@ -192,13 +205,16 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
.processingUrl("/webauthn/attestation/options")
.processingUrl("/webauthn/attestation/options")
.user(new MyPublicKeyCredentialUserEntityProvider()) // put your PublicKeyCredentialUserEntityProvider implementation
.user(new MyPublicKeyCredentialUserEntityProvider()); // put your PublicKeyCredentialUserEntityProvider implementation
});
}
}
----
Expand Down
62 changes: 39 additions & 23 deletions docs/src/reference/asciidoc/ja/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,36 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
http.authenticationManager(authenticationManager);
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
.loginPage("/login")
.usernameParameter("username")
.passwordParameter("rawPassword")
.credentialIdParameter("credentialId")
.clientDataJSONParameter("clientDataJSON")
.authenticatorDataParameter("authenticatorData")
.signatureParameter("signature")
.clientExtensionsJSONParameter("clientExtensionsJSON")
.loginProcessingUrl("/login")
.rpId("example.com")
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
.and()
.assertionOptionsEndpoint()
.assertionOptionsProvider(assertionOptionsProvider)
.and()
.authenticationManager(authenticationManager);
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.loginPage("/login")
.usernameParameter("username")
.passwordParameter("password")
.credentialIdParameter("credentialId")
.clientDataJSONParameter("clientDataJSON")
.authenticatorDataParameter("authenticatorData")
.signatureParameter("signature")
.clientExtensionsJSONParameter("clientExtensionsJSON")
.loginProcessingUrl("/login")
.attestationOptionsEndpoint()
.rp()
.name("WebAuthn4J Spring Security Sample")
.and()
.pubKeyCredParams(
new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS256), // Windows Hello
new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256) // FIDO U2F Key, etc
)
.extensions()
.credProps(true)
.and()
.assertionOptionsEndpoint()
.and()
.successHandler(authenticationSuccessHandler)
.failureHandler(authenticationFailureHandler);
});
}
}
----
Expand Down Expand Up @@ -149,8 +160,10 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
http.authenticationManager(authenticationManager);
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.rpId("example.com")
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
Expand All @@ -177,8 +190,8 @@ public class WebSecurityConfig {
.processingUrl("/webauthn/assertion/options")
.rpId("example.com")
.userVerification(UserVerificationRequirement.PREFERRED)
.and()
.authenticationManager(authenticationManager);
.and();
});
}
}
----
Expand All @@ -197,13 +210,16 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception {
// WebAuthn Login
http.apply(WebAuthnLoginConfigurer.webAuthnLogin())
http.with(WebAuthnLoginConfigurer.webAuthnLogin(), (customizer) ->{
customizer
.attestationOptionsEndpoint()
.attestationOptionsProvider(attestationOptionsProvider)
.processingUrl("/webauthn/attestation/options")
.processingUrl("/webauthn/attestation/options")
.user(new MyPublicKeyCredentialUserEntityProvider()) // put your PublicKeyCredentialUserEntityProvider implementation
.user(new MyPublicKeyCredentialUserEntityProvider()); // put your PublicKeyCredentialUserEntityProvider implementation
});
}
}
----
Expand Down

0 comments on commit dc63853

Please sign in to comment.