From 05915aae3077f3f613df255e590c9a1d1257534f Mon Sep 17 00:00:00 2001 From: Jack Mechem Date: Fri, 1 May 2026 16:19:51 -0700 Subject: [PATCH] Fix nfc --- src/auth.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 7fae332..3fb190f 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -32,13 +32,13 @@ const RP_ORIGIN: &str = "https://dashboard.jackmechem.dev"; #[derive(Serialize, Deserialize)] struct StoredCredentials { user_id: Uuid, - credentials: Vec, + credentials: Vec, } pub struct AppState { pub webauthn: Webauthn, - pending_auth: Mutex>, - pending_reg: Mutex>, + pending_auth: Mutex>, + pending_reg: Mutex>, } impl AppState { @@ -246,7 +246,7 @@ pub async fn post_login( let (rcr, auth_state) = match state .webauthn - .start_passkey_authentication(&stored.credentials) + .start_securitykey_authentication(&stored.credentials) { Ok(r) => r, Err(e) => { @@ -258,7 +258,7 @@ pub async fn post_login( let session_id = generate_session_id(); { let mut pending = state.pending_auth.lock().unwrap(); - pending.retain(|_, (_, created, _)| created.elapsed() < CHALLENGE_TTL); + pending.retain(|_, (_, t, _)| t.elapsed() < CHALLENGE_TTL); pending.insert(session_id.clone(), (auth_state, Instant::now(), username)); } @@ -294,7 +294,7 @@ pub async fn post_verify( let auth_result = match state .webauthn - .finish_passkey_authentication(&body.credential, &auth_state) + .finish_securitykey_authentication(&body.credential, &auth_state) { Ok(r) => r, Err(e) => { @@ -344,7 +344,7 @@ pub async fn post_register_start( let (ccr, reg_state) = match state .webauthn - .start_passkey_registration(user_id, &username, &username, exclude) + .start_securitykey_registration(user_id, &username, &username, exclude, None, None) { Ok(r) => r, Err(e) => { @@ -356,7 +356,7 @@ pub async fn post_register_start( let session_id = generate_session_id(); { let mut pending = state.pending_reg.lock().unwrap(); - pending.retain(|_, (_, created, _, _)| created.elapsed() < CHALLENGE_TTL); + pending.retain(|_, (_, t, _, _)| t.elapsed() < CHALLENGE_TTL); pending.insert( session_id.clone(), (reg_state, Instant::now(), username, user_id), @@ -395,7 +395,7 @@ pub async fn post_register_finish( let passkey = match state .webauthn - .finish_passkey_registration(&body.credential, ®_state) + .finish_securitykey_registration(&body.credential, ®_state) { Ok(p) => p, Err(e) => { @@ -408,6 +408,7 @@ pub async fn post_register_finish( user_id, credentials: vec![], }); + stored.credentials.push(passkey); if let Err(e) = save_credentials(&username, &stored) {