diff --git a/samples/mpa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/app/config/WebSecurityConfig.java b/samples/mpa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/app/config/WebSecurityConfig.java index 002c69eb6..9e4dd8de2 100644 --- a/samples/mpa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/app/config/WebSecurityConfig.java +++ b/samples/mpa/src/main/java/com/webauthn4j/springframework/security/webauthn/sample/app/config/WebSecurityConfig.java @@ -20,6 +20,7 @@ import com.webauthn4j.data.AttestationConveyancePreference; import com.webauthn4j.data.PublicKeyCredentialParameters; import com.webauthn4j.data.PublicKeyCredentialType; +import com.webauthn4j.data.ResidentKeyRequirement; import com.webauthn4j.data.attestation.statement.COSEAlgorithmIdentifier; import com.webauthn4j.springframework.security.WebAuthnAuthenticationProvider; import com.webauthn4j.springframework.security.authenticator.WebAuthnAuthenticatorService; @@ -32,9 +33,12 @@ import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.ProviderManager; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.access.expression.DefaultHttpSecurityExpressionHandler; import org.springframework.security.web.access.expression.WebExpressionAuthorizationManager; @@ -54,6 +58,14 @@ public WebAuthnAuthenticationProvider webAuthnAuthenticationProvider(WebAuthnAut return new WebAuthnAuthenticationProvider(authenticatorService, webAuthnManager); } + @Bean + public DaoAuthenticationProvider daoAuthenticationProvider(PasswordEncoder passwordEncoder, UserDetailsService userDetailsService){ + DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); + daoAuthenticationProvider.setPasswordEncoder(passwordEncoder); + daoAuthenticationProvider.setUserDetailsService(userDetailsService); + return daoAuthenticationProvider; + } + @Bean public AuthenticationManager authenticationManager(List providers){ return new ProviderManager(providers); @@ -79,13 +91,13 @@ public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager .failureUrl("/login") .attestationOptionsEndpoint() .rp() - .name("WebAuthn4J Spring Security Sample MPA") + .name("WebAuthn4J Spring Security Sample") .and() .pubKeyCredParams( new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256), new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS1) ) - .attestation(AttestationConveyancePreference.DIRECT) + .attestation(AttestationConveyancePreference.NONE) .extensions() .uvm(true) .credProps(true) diff --git a/samples/mpa/src/main/resources/static/css/tiny.css b/samples/mpa/src/main/resources/static/css/tiny.css index 4815ab563..bd74cea26 100644 --- a/samples/mpa/src/main/resources/static/css/tiny.css +++ b/samples/mpa/src/main/resources/static/css/tiny.css @@ -22,14 +22,10 @@ } .login-form input#username { - margin-bottom: -1px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; + margin-bottom: 1em; } .login-form input#password { - margin-bottom: 10px; - border-top-left-radius: 0; - border-top-right-radius: 0; + margin-bottom: 1em; } .signup-form input#username { diff --git a/samples/mpa/src/main/resources/static/js/webauthn.js b/samples/mpa/src/main/resources/static/js/webauthn.js index e3ef46e35..2a5fa050e 100644 --- a/samples/mpa/src/main/resources/static/js/webauthn.js +++ b/samples/mpa/src/main/resources/static/js/webauthn.js @@ -1,5 +1,5 @@ -function createCredential(residentKeyRequirement){ +function createCredential(){ let username = $("#username").val(); let userHandle = $("#userHandle").val(); @@ -25,7 +25,8 @@ function createCredential(residentKeyRequirement){ } }), authenticatorSelection: { - requireResidentKey: residentKeyRequirement + requireResidentKey: true, + residentKey: "preferred" }, attestation: options.attestation, extensions: options.extensions @@ -65,10 +66,9 @@ function getCredential(userVerification){ $(document).ready(function() { - let dialog = $("#resident-key-requirement-dialog"); - let onResidentKeyRequirementDialogClosing = function(residentKeyRequirement){ - createCredential(residentKeyRequirement).then(function (credential) { + $('#authenticator').click(function(){ + createCredential().then(function (credential) { console.log(credential); $('#clientDataJSON').val(base64url.encodeBase64url(credential.response.clientDataJSON)); $('#attestationObject').val(base64url.encodeBase64url(credential.response.attestationObject)); @@ -76,25 +76,9 @@ $(document).ready(function() { $('#authenticator').text('Authenticator registered'); $('#authenticator').prop('disabled', true); $('#submit').prop('disabled', false); - dialog.modal('hide'); }).catch(function (e) { console.error("Error:%s, Message:%s", e.name, e.message); - dialog.modal('hide'); }); - }; - - $('#resident-key-requirement-dialog-yes').click(function () { - onResidentKeyRequirementDialogClosing(true); - }); - $('#resident-key-requirement-dialog-no').click(function () { - onResidentKeyRequirementDialogClosing(false); - }); - $('#resident-key-requirement-dialog-close').click(function () { - dialog.modal('hide'); - }); - - $('#authenticator').click(function(){ - dialog.modal('show'); }); $('#fast-login').click(function(){ diff --git a/samples/mpa/src/main/resources/templates/dashboard/dashboard.html b/samples/mpa/src/main/resources/templates/dashboard/dashboard.html index 018db65dd..7fb86e821 100644 --- a/samples/mpa/src/main/resources/templates/dashboard/dashboard.html +++ b/samples/mpa/src/main/resources/templates/dashboard/dashboard.html @@ -25,7 +25,7 @@
-

WebAuthn4J Spring Security Sample MPA

+

WebAuthn4J Spring Security Sample

Login success

diff --git a/samples/mpa/src/main/resources/templates/login/authenticator-login.html b/samples/mpa/src/main/resources/templates/login/authenticator-login.html index a6e782a26..4c56ef3df 100644 --- a/samples/mpa/src/main/resources/templates/login/authenticator-login.html +++ b/samples/mpa/src/main/resources/templates/login/authenticator-login.html @@ -25,7 +25,7 @@
-

WebAuthn4J Spring Security Sample MPA

+

WebAuthn4J Spring Security Sample

Login

diff --git a/samples/mpa/src/main/resources/templates/login/login.html b/samples/mpa/src/main/resources/templates/login/login.html index ead0d4f99..615a9b9fc 100644 --- a/samples/mpa/src/main/resources/templates/login/login.html +++ b/samples/mpa/src/main/resources/templates/login/login.html @@ -25,7 +25,7 @@
-

WebAuthn4J Spring Security Sample MPA

+

WebAuthn4J Spring Security Sample

Login

@@ -43,7 +43,7 @@

Login

OR

+ title="Passkey Login">Passkey Login
@@ -58,54 +58,6 @@

Login