@@ -279,8 +279,8 @@ impl PasskeyApplication {
279279 /// Takes `WebAuthn`'s verdict on an assertion for `user_id` and, once the latest
280280 /// credential state also accepts it, opens the transaction that completes the
281281 /// authentication. The ceremony was already consumed. A
282- /// [`PasskeyError::CounterRegression`] rolls this transaction back , then commits
283- /// its audit entry on the pool so the record outlives the rejection.
282+ /// [`PasskeyError::CounterRegression`] rolls back any transaction it opened , then
283+ /// commits its audit entry on the pool so the record outlives the rejection.
284284 async fn accept_credential (
285285 & self ,
286286 user_id : UserId ,
@@ -305,8 +305,15 @@ impl PasskeyApplication {
305305 %user_id,
306306 "passkey signature counter regression rejected"
307307 ) ;
308- if let Some ( tx) = tx {
309- tx. rollback ( ) . await ?;
308+ // A failed rollback is only logged: the audit entry matters more, and a broken
309+ // connection releases its locks anyway.
310+ if let Some ( tx) = tx
311+ && let Err ( rollback) = tx. rollback ( ) . await
312+ {
313+ tracing:: error!(
314+ error = %piquel_common:: ErrorChain ( & rollback) ,
315+ "passkey authentication rollback failed"
316+ ) ;
310317 }
311318 self . database
312319 . audit_events ( )
@@ -406,7 +413,7 @@ impl PasskeyApplication {
406413 let key = app
407414 . webauthn
408415 . finish_passkey_registration ( & input. credential , & state)
409- . map_err ( PasskeyError :: Webauthn ) ?;
416+ . map_err ( PasskeyError :: from ) ?;
410417 let mut tx = app. database . begin ( ) . await ?;
411418 if app. invite_required
412419 && !tx
@@ -470,7 +477,7 @@ impl PasskeyApplication {
470477 let ( mut challenge, state) = app
471478 . webauthn
472479 . start_passkey_authentication ( & Self :: decode ( keys) ?)
473- . map_err ( PasskeyError :: Webauthn ) ?;
480+ . map_err ( PasskeyError :: from ) ?;
474481 let ceremony = if let Some ( user_id) = user_id {
475482 Ceremony :: Login ( LoginCeremony { user_id, state } )
476483 } else {
@@ -485,7 +492,7 @@ impl PasskeyApplication {
485492 let ( mut challenge, state) = app
486493 . webauthn
487494 . start_discoverable_authentication ( )
488- . map_err ( PasskeyError :: Webauthn ) ?;
495+ . map_err ( PasskeyError :: from ) ?;
489496 challenge. mediation = None ;
490497 ( Ceremony :: Discover ( DiscoverCeremony { state } ) , challenge)
491498 } ;
@@ -512,7 +519,7 @@ impl PasskeyApplication {
512519 let ( uuid, _) = app
513520 . webauthn
514521 . identify_discoverable_authentication ( & input. credential )
515- . map_err ( PasskeyError :: Webauthn ) ?;
522+ . map_err ( PasskeyError :: from ) ?;
516523 let user_id = UserId :: from_uuid ( uuid) . map_err ( PasskeyError :: InvalidUserHandle ) ?;
517524 let keys: Vec < DiscoverableKey > = app
518525 . keys ( user_id)
@@ -543,7 +550,7 @@ impl PasskeyApplication {
543550 let ( challenge, state) = app
544551 . webauthn
545552 . start_passkey_authentication ( & app. keys ( session. user_id ) . await ?)
546- . map_err ( PasskeyError :: Webauthn ) ?;
553+ . map_err ( PasskeyError :: from ) ?;
547554 Ok ( app
548555 . start (
549556 & headers,
@@ -654,7 +661,7 @@ impl PasskeyApplication {
654661 let key = app
655662 . webauthn
656663 . finish_passkey_registration ( & input. credential , & state)
657- . map_err ( PasskeyError :: Webauthn ) ?;
664+ . map_err ( PasskeyError :: from ) ?;
658665 let mut tx = app. database . begin ( ) . await ?;
659666 Self :: lock_management ( & mut tx, & session) . await ?;
660667 Self :: insert_passkey ( & mut tx, user_id, key, friendly_name) . await ?;
0 commit comments