@@ -385,7 +385,7 @@ impl FromInnerModel<PublicKeyCredentialCreationOptionsJSON, MakeCredentialReques
385385 let user_verification = inner
386386 . authenticator_selection
387387 . as_ref ( )
388- . map_or ( UserVerificationRequirement :: Discouraged , |s| {
388+ . map_or ( UserVerificationRequirement :: Preferred , |s| {
389389 s. user_verification
390390 } ) ;
391391
@@ -793,6 +793,42 @@ mod tests {
793793 assert_eq ! ( req. timeout, DEFAULT_TIMEOUT ) ;
794794 }
795795
796+ /// Per spec, when authenticatorSelection is missing, userVerification should default to "preferred".
797+ /// https://www.w3.org/TR/webauthn-3/#dom-authenticatorselectioncriteria-userverification
798+ #[ test]
799+ fn test_request_from_json_default_user_verification_preferred ( ) {
800+ let rpid = RelyingPartyId :: try_from ( "example.org" ) . unwrap ( ) ;
801+ let req_json = json_field_rm ( REQUEST_BASE_JSON , "authenticatorSelection" ) ;
802+
803+ let req: MakeCredentialRequest =
804+ MakeCredentialRequest :: from_json ( & rpid, & req_json) . unwrap ( ) ;
805+ assert_eq ! (
806+ req. user_verification,
807+ UserVerificationRequirement :: Preferred
808+ ) ;
809+ }
810+
811+ /// Per spec, when userVerification is missing inside authenticatorSelection,
812+ /// it should default to "preferred".
813+ #[ test]
814+ fn test_request_from_json_missing_user_verification_in_authenticator_selection ( ) {
815+ let rpid = RelyingPartyId :: try_from ( "example.org" ) . unwrap ( ) ;
816+ // Replace authenticatorSelection with one that has no userVerification field
817+ let mut req_json = json_field_rm ( REQUEST_BASE_JSON , "authenticatorSelection" ) ;
818+ req_json = json_field_add (
819+ & req_json,
820+ "authenticatorSelection" ,
821+ r#"{"residentKey": "discouraged"}"# ,
822+ ) ;
823+
824+ let req: MakeCredentialRequest =
825+ MakeCredentialRequest :: from_json ( & rpid, & req_json) . unwrap ( ) ;
826+ assert_eq ! (
827+ req. user_verification,
828+ UserVerificationRequirement :: Preferred
829+ ) ;
830+ }
831+
796832 // Tests for response JSON serialization
797833
798834 fn create_test_response ( ) -> MakeCredentialResponse {
0 commit comments