Title: [294122] trunk/Source
Revision
294122
Author
[email protected]
Date
2022-05-12 14:51:58 -0700 (Thu, 12 May 2022)

Log Message

[WebAuthn] Include backup state in authenticatorData
https://bugs.webkit.org/show_bug.cgi?id=240353
rdar://problem/93191958

Reviewed by Brent Fulgham.

Source/WebCore:

Add flags for credential backup state: https://github.com/w3c/webauthn/pull/1695

* Modules/webauthn/WebAuthenticationConstants.h:

Source/WebKit:

This patch adds support for backup state flags, which will be added to
the Web Authentication spec soon via https://github.com/w3c/webauthn/pull/1695

These flags are set whenever a credential is "backup eligible" and "backed up"
hinting to RPs that the credential is "durable" and may persist through device
restores. This is useful for RPs that may choose to offer to remove the user
password if a credental is in this state.

* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticatorInternal::authDataFlags):
(WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):
(WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (294121 => 294122)


--- trunk/Source/WebCore/ChangeLog	2022-05-12 21:30:42 UTC (rev 294121)
+++ trunk/Source/WebCore/ChangeLog	2022-05-12 21:51:58 UTC (rev 294122)
@@ -1,3 +1,15 @@
+2022-05-12  J Pascoe  <[email protected]>
+
+        [WebAuthn] Include backup state in authenticatorData
+        https://bugs.webkit.org/show_bug.cgi?id=240353
+        rdar://problem/93191958
+
+        Reviewed by Brent Fulgham.
+
+        Add flags for credential backup state: https://github.com/w3c/webauthn/pull/1695
+
+        * Modules/webauthn/WebAuthenticationConstants.h:
+
 2022-05-12  Brent Fulgham  <[email protected]>
 
         REGRESSION (r281791): [iOS] WKWebView cannot load local .log file

Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (294121 => 294122)


--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-05-12 21:30:42 UTC (rev 294121)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-05-12 21:51:58 UTC (rev 294122)
@@ -110,5 +110,8 @@
 constexpr uint8_t userPresenceFlag = 0b00000001;
 constexpr uint8_t userVerifiedFlag = 0b00000100;
 constexpr uint8_t attestedCredentialDataIncludedFlag = 0b01000000;
+// https://github.com/w3c/webauthn/pull/1695
+constexpr uint8_t backupEligibilityFlag = 0b00001000;
+constexpr uint8_t backupStateFlag = 0b00010000;
 
 } // namespace WebAuthn

Modified: trunk/Source/WebKit/ChangeLog (294121 => 294122)


--- trunk/Source/WebKit/ChangeLog	2022-05-12 21:30:42 UTC (rev 294121)
+++ trunk/Source/WebKit/ChangeLog	2022-05-12 21:51:58 UTC (rev 294122)
@@ -1,3 +1,24 @@
+2022-05-12  J Pascoe  <[email protected]>
+
+        [WebAuthn] Include backup state in authenticatorData
+        https://bugs.webkit.org/show_bug.cgi?id=240353
+        rdar://problem/93191958
+
+        Reviewed by Brent Fulgham.
+
+        This patch adds support for backup state flags, which will be added to
+        the Web Authentication spec soon via https://github.com/w3c/webauthn/pull/1695
+
+        These flags are set whenever a credential is "backup eligible" and "backed up"
+        hinting to RPs that the credential is "durable" and may persist through device
+        restores. This is useful for RPs that may choose to offer to remove the user
+        password if a credental is in this state.
+
+        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+        (WebKit::LocalAuthenticatorInternal::authDataFlags):
+        (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):
+        (WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification):
+
 2022-05-12  Tim Horton  <[email protected]>
 
         Don't install WebKit feature flags plist on macOS

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (294121 => 294122)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2022-05-12 21:30:42 UTC (rev 294121)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2022-05-12 21:51:58 UTC (rev 294122)
@@ -75,11 +75,6 @@
 
 namespace LocalAuthenticatorInternal {
 
-// See https://www.w3.org/TR/webauthn/#flags.
-const uint8_t makeCredentialFlags = userPresenceFlag | userVerifiedFlag | attestedCredentialDataIncludedFlag; // UP, UV and AT are set.
-const uint8_t otherMakeCredentialFlags = userPresenceFlag | attestedCredentialDataIncludedFlag; // UP and AT are set.
-const uint8_t getAssertionFlags = userPresenceFlag | userVerifiedFlag; // UP and UV are set.
-const uint8_t otherGetAssertionFlags = userPresenceFlag; // UP is set.
 // Credential ID is currently SHA-1 of the corresponding public key.
 const uint16_t credentialIdLength = 20;
 const uint64_t counter = 0;
@@ -101,6 +96,18 @@
     return result;
 }
 
+static inline uint8_t authDataFlags(ClientDataType type, LocalConnection::UserVerification verification, bool synchronizable)
+{
+    auto flags = userPresenceFlag;
+    if (verification != LocalConnection::UserVerification::Presence)
+        flags |= userVerifiedFlag;
+    if (type == ClientDataType::Create)
+        flags |= attestedCredentialDataIncludedFlag;
+    if (synchronizable)
+        flags |= backupEligibilityFlag | backupStateFlag;
+    return flags;
+}
+
 static inline Vector<uint8_t> aaguidVector()
 {
     static NeverDestroyed<Vector<uint8_t>> aaguidVector = { aaguid, aaguidLength };
@@ -451,7 +458,7 @@
         cosePublicKey = encodeES256PublicKeyAsCBOR(WTFMove(x), WTFMove(y));
     }
 
-    auto flags = verification == LocalConnection::UserVerification::Presence ? otherMakeCredentialFlags : makeCredentialFlags;
+    auto flags = authDataFlags(ClientDataType::Create, verification, shouldUpdateQuery());
     // Step 12.
     // Skip Apple Attestation for none attestation.
     if (creationOptions.attestation == AttestationConveyancePreference::None) {
@@ -622,7 +629,8 @@
 
     // Step 10.
     auto requestOptions = std::get<PublicKeyCredentialRequestOptions>(requestData().options);
-    auto authData = buildAuthData(requestOptions.rpId, verification == LocalConnection::UserVerification::Presence ? otherGetAssertionFlags : getAssertionFlags, counter, { });
+    auto flags = authDataFlags(ClientDataType::Get, verification, response->synchronizable());
+    auto authData = buildAuthData(requestOptions.rpId, flags, counter, { });
 
     // Step 11.
     RetainPtr<CFDataRef> signature;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to