@@ -87,17 +87,17 @@ pub trait WebAuthn {
8787
8888pub ( crate ) async fn select_uv_proto (
8989 get_info_response : & Ctap2GetInfoResponse ,
90- ) -> Result < Box < dyn PinUvAuthProtocol > , Error > {
90+ ) -> Option < Box < dyn PinUvAuthProtocol > > {
9191 for & protocol in get_info_response. pin_auth_protos . iter ( ) . flatten ( ) {
9292 match protocol {
93- 1 => return Ok ( Box :: new ( PinUvAuthProtocolOne :: new ( ) ) ) ,
94- 2 => return Ok ( Box :: new ( PinUvAuthProtocolTwo :: new ( ) ) ) ,
93+ 1 => return Some ( Box :: new ( PinUvAuthProtocolOne :: new ( ) ) ) ,
94+ 2 => return Some ( Box :: new ( PinUvAuthProtocolTwo :: new ( ) ) ) ,
9595 _ => ( ) ,
9696 } ;
9797 }
9898
99- error ! ( ?get_info_response. pin_auth_protos, "No supported PIN/UV auth protocols found" ) ;
100- Err ( Error :: Ctap ( CtapError :: Other ) )
99+ warn ! ( ?get_info_response. pin_auth_protos, "No supported PIN/UV auth protocols found" ) ;
100+ None
101101}
102102
103103#[ async_trait]
@@ -310,18 +310,21 @@ where
310310{
311311 let get_info_response = channel. ctap2_get_info ( ) . await ?;
312312 ctap2_request. handle_legacy_preview ( & get_info_response) ;
313- let uv_proto = select_uv_proto ( & get_info_response) . await ?;
314- let token_identifier = Ctap2AuthTokenPermission :: new (
315- uv_proto. version ( ) ,
316- ctap2_request. permissions ( ) ,
317- ctap2_request. permissions_rpid ( ) ,
318- ) ;
319- if let Some ( uv_auth_token) = channel. get_uv_auth_token ( & token_identifier) {
320- ctap2_request. calculate_and_set_uv_auth ( & uv_proto, uv_auth_token) ;
321- Ok ( UsedPinUvAuthToken :: FromStorage )
322- } else {
323- user_verification_helper ( channel, user_verification, ctap2_request, timeout) . await
313+ let maybe_uv_proto = select_uv_proto ( & get_info_response) . await ;
314+
315+ if let Some ( uv_proto) = maybe_uv_proto {
316+ let token_identifier = Ctap2AuthTokenPermission :: new (
317+ uv_proto. version ( ) ,
318+ ctap2_request. permissions ( ) ,
319+ ctap2_request. permissions_rpid ( ) ,
320+ ) ;
321+ if let Some ( uv_auth_token) = channel. get_uv_auth_token ( & token_identifier) {
322+ ctap2_request. calculate_and_set_uv_auth ( & uv_proto, uv_auth_token) ;
323+ return Ok ( UsedPinUvAuthToken :: FromStorage ) ;
324+ }
324325 }
326+
327+ user_verification_helper ( channel, user_verification, ctap2_request, timeout) . await
325328}
326329
327330#[ instrument( skip_all) ]
@@ -378,7 +381,11 @@ where
378381 return Ok ( UsedPinUvAuthToken :: LegacyUV ) ;
379382 }
380383
381- let uv_proto = select_uv_proto ( & get_info_response) . await ?;
384+ let Some ( uv_proto) = select_uv_proto ( & get_info_response) . await else {
385+ error ! ( "No supported PIN/UV auth protocols found" ) ;
386+ return Err ( Error :: Ctap ( CtapError :: Other ) ) ;
387+ } ;
388+
382389 // For operations that include a PIN, we want to fetch one before obtaining a shared secret.
383390 // This prevents the shared secret from expiring whilst we wait for the user to enter a PIN.
384391 let pin = match uv_operation {
0 commit comments