Title: [285267] trunk/Source/WebKit
Revision
285267
Author
[email protected]
Date
2021-11-04 10:40:39 -0700 (Thu, 04 Nov 2021)

Log Message

[WebAuthn] Implement add/remove_virtual_authenticator for transport=internal
https://bugs.webkit.org/show_bug.cgi?id=232635
<rdar://problem/84942173>

Patch by John Pascoe <[email protected]> on 2021-11-04
Reviewed by Brent Fulgham.

This change implements much of the plumbing needed to call the virtual authenticator
commands from safaridriver. The idea is that virtual authenticators are added via
the add_virtual_authenticator call, which replaces the default AuthenticatorManager
with a VirtualAuthenticatorManager similar to how we do it for mocks. Then the
VirtualService will create the virtual connections for authenticators as nessesary
to make webauthn calls within WebDriver based tests.

Tested manually via safaridriver.

* UIProcess/Automation/Automation.json:
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::toAuthenticatorTransport):
(WebKit::WebAutomationSession::removeVirtualAuthenticator):
(WebKit::WebAutomationSession::addVirtualAuthenticatorCredential):
(WebKit::WebAutomationSession::removeVirtualAuthenticatorCredential):
(WebKit::WebAutomationSession::removeAllVirtualAuthenticatorCredentials):
(WebKit::WebAutomationSession::setVirtualAuthenticatorUserVerified):
* UIProcess/Automation/WebAutomationSession.h:
Plumbing to call from safaridriver
* UIProcess/WebAuthentication/AuthenticatorManager.h:
(WebKit::AuthenticatorManager::isVirtual const):
* UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorConfiguration.h: Added.
* UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.cpp: Added.
(WebKit::VirtualAuthenticatorManager::VirtualAuthenticatorManager):
(WebKit::VirtualAuthenticatorManager::createAuthenticator):
(WebKit::VirtualAuthenticatorManager::removeAuthenticator):
(WebKit::VirtualAuthenticatorManager::createService const):
Manages virtual authenticators, replaces the default manager when used similar to MockAuthenticatorManager.
* UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.h: Added.
* UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.h: Added.
* UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.mm: Added.
(WebKit::VirtualLocalConnection::VirtualLocalConnection):
(WebKit::VirtualLocalConnection::verifyUser):
(WebKit::VirtualLocalConnection::getAttestation const):
(WebKit::VirtualLocalConnection::filterResponses const):
* UIProcess/WebAuthentication/Virtual/VirtualService.h: Added.
* UIProcess/WebAuthentication/Virtual/VirtualService.mm: Added.
(WebKit::VirtualService::VirtualService):
(WebKit::VirtualService::createVirtual):
(WebKit::VirtualService::startDiscoveryInternal):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::virtualAuthenticatorManager):
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (285266 => 285267)


--- trunk/Source/WebKit/ChangeLog	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/ChangeLog	2021-11-04 17:40:39 UTC (rev 285267)
@@ -1,3 +1,56 @@
+2021-11-04  John Pascoe  <[email protected]>
+
+        [WebAuthn] Implement add/remove_virtual_authenticator for transport=internal
+        https://bugs.webkit.org/show_bug.cgi?id=232635
+        <rdar://problem/84942173>
+
+        Reviewed by Brent Fulgham.
+
+        This change implements much of the plumbing needed to call the virtual authenticator
+        commands from safaridriver. The idea is that virtual authenticators are added via
+        the add_virtual_authenticator call, which replaces the default AuthenticatorManager
+        with a VirtualAuthenticatorManager similar to how we do it for mocks. Then the
+        VirtualService will create the virtual connections for authenticators as nessesary
+        to make webauthn calls within WebDriver based tests.
+
+        Tested manually via safaridriver.
+
+        * UIProcess/Automation/Automation.json:
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::toAuthenticatorTransport):
+        (WebKit::WebAutomationSession::removeVirtualAuthenticator):
+        (WebKit::WebAutomationSession::addVirtualAuthenticatorCredential):
+        (WebKit::WebAutomationSession::removeVirtualAuthenticatorCredential):
+        (WebKit::WebAutomationSession::removeAllVirtualAuthenticatorCredentials):
+        (WebKit::WebAutomationSession::setVirtualAuthenticatorUserVerified):
+        * UIProcess/Automation/WebAutomationSession.h:
+        Plumbing to call from safaridriver
+        * UIProcess/WebAuthentication/AuthenticatorManager.h:
+        (WebKit::AuthenticatorManager::isVirtual const):
+        * UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorConfiguration.h: Added.
+        * UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.cpp: Added.
+        (WebKit::VirtualAuthenticatorManager::VirtualAuthenticatorManager):
+        (WebKit::VirtualAuthenticatorManager::createAuthenticator):
+        (WebKit::VirtualAuthenticatorManager::removeAuthenticator):
+        (WebKit::VirtualAuthenticatorManager::createService const):
+        Manages virtual authenticators, replaces the default manager when used similar to MockAuthenticatorManager.
+        * UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.h: Added.
+        * UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.h: Added.
+        * UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.mm: Added.
+        (WebKit::VirtualLocalConnection::VirtualLocalConnection):
+        (WebKit::VirtualLocalConnection::verifyUser):
+        (WebKit::VirtualLocalConnection::getAttestation const):
+        (WebKit::VirtualLocalConnection::filterResponses const):
+        * UIProcess/WebAuthentication/Virtual/VirtualService.h: Added.
+        * UIProcess/WebAuthentication/Virtual/VirtualService.mm: Added.
+        (WebKit::VirtualService::VirtualService):
+        (WebKit::VirtualService::createVirtual):
+        (WebKit::VirtualService::startDiscoveryInternal):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::virtualAuthenticatorManager):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2021-11-04  Lauro Moura  <[email protected]>
 
         REGRESSION(r285077) [GLIB] 'MemoryPressureMonitor' has not been declared

Modified: trunk/Source/WebKit/UIProcess/Automation/Automation.json (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/Automation/Automation.json	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/Automation/Automation.json	2021-11-04 17:40:39 UTC (rev 285267)
@@ -335,6 +335,56 @@
                 { "name": "delta", "$ref": "Size", "optional": true, "description": "For 'wheel' input sources, specifies a scroll delta."},
                 { "name": "duration", "type": "integer", "optional": true, "description": "The minimum number of milliseconds that must elapse while the relevant input source transitions to this state." }
             ]
+        },
+        {
+            "id": "AuthenticatorProtocol",
+            "type": "string",
+            "description": "This enum contains the different protocol types supported by virtual authenticators.",
+            "enum": [
+                "ctap1_u2f",
+                "ctap2",
+                "ctap2_1"
+            ]
+        },
+        {
+            "id": "AuthenticatorTransport",
+            "type": "string",
+            "description": "Authenticators may implement various transports for communicating with clients. This enumeration defines hints as to how clients might communicate with a particular authenticator in order to obtain an assertion for a specific credential.",
+            "enum": [
+                "usb",
+                "nfc",
+                "ble",
+                "internal"
+            ]
+        },
+        {
+            "id": "VirtualAuthenticatorCredential",
+            "type": "object",
+            "description": "A credential object used for virtual authenticators.",
+            "properties": [
+                { "name": "credentialId", "type": "string", "description": "The Credential ID encoded using Base64url Encoding."},
+                { "name": "isResidentCredential", "type": "boolean", "description": "If set to true, a client-side discoverable credential is created. If set to false, a server-side credential is created instead."},
+                { "name": "rpId", "type": "string", "description": "The Relying Party ID the credential is scoped to."},
+                { "name": "privateKey", "type": "string", "description": "An asymmetric key package containing a single private key per [RFC5958], encoded using Base64url Encoding." },
+                { "name": "userHandle", "type": "string", "optional": true, "description": "The userHandle associated to the credential encoded using Base64url Encoding. This property may not be defined." },
+                { "name": "signCount", "type": "integer", "description": "The initial value for a signature counter associated to the public key credential source." },
+                { "name": "largeBlob", "type": "string", "optional": true, "description": "The large, per-credential blob associated to the public key credential source, encoded using Base64url Encoding. This property may not be defined." }
+            ]
+        },
+        {
+            "id": "VirtualAuthenticatorConfiguration",
+            "type": "object",
+            "description": "Parameters used when creating a virtual authenticator",
+            "properties": [
+                { "name": "protocol", "$ref": "AuthenticatorProtocol", "description": "The protocol of the authenticator" },
+                { "name": "transport", "$ref": "AuthenticatorTransport", "description": "The transport of the protocol" },
+                { "name": "hasResidentKey", "type": "boolean", "optional": true, "description": "If the authenticator has a resident key" },
+                { "name": "hasUserVerification", "type": "boolean", "optional": true, "description": "If the authenticator supports user verification" },
+                { "name": "isUserConsenting", "type": "boolean", "optional": true, "description": "If the virtual authenticator should consent to requests"},
+                { "name": "isUserVerified", "type": "boolean", "optional": true, "description": "If user verification requests should succeeed"},
+                { "name": "extensions", "type": "array", "items": {"type": "string"}, "optional": true, "description": "An array containing extension identifiers" },
+                { "name": "uvm", "type": "array", "items": {"type": "integer"}, "optional": true, "description": "Up to 3 User Verification Method entries"}
+            ]
         }
     ],
     "commands": [
@@ -713,6 +763,71 @@
             "parameters": [
                 { "name": "permissions", "type": "array", "items": { "$ref": "SessionPermissionData" }, "description": "Array of session permissions to set, if they are available." }
             ]
+        },
+        {
+            "name": "addVirtualAuthenticator",
+            "description": "Adds a virtual web authentication authenticator for the specified browsing context.",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticator", "$ref": "VirtualAuthenticatorConfiguration", "description": "The configuration for the virtual authenticator to be created." }
+            ],
+            "returns": [
+                { "name": "authenticatorId", "type": "string", "description": "The authenticatorId of the created authenticator" }
+            ]
+        },
+        {
+            "name": "removeVirtualAuthenticator",
+            "description": "Removes a virtual web authentication authenticator for the specified browsing context.",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to remove." }
+            ]
+        },
+        {
+            "name": "addVirtualAuthenticatorCredential",
+            "description": "Add a credential to a specified virutal authenticator for the specified browsing context",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to add the credential to." },
+                { "name": "credential", "$ref": "VirtualAuthenticatorCredential", "description": "The parameters of the credential to add." }
+            ]
+        },
+        {
+            "name": "getVirtualAuthenticatorCredentials",
+            "description": "Get all credentials for a given virtual authenticator for the specified browsing context",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to fetch all credentials for." }
+            ],
+            "returns": [
+                { "name": "credentials", "type": "array", "items": { "$ref": "VirtualAuthenticatorCredential" }, "description": "Array of credentials for given virtual authenticator" }
+            ]
+        },
+        {
+            "name": "removeVirtualAuthenticatorCredential",
+            "description": "Remove a credential from a virtual authenticator for the specified browsing context",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to fetch all credentials for." },
+                { "name": "credentialId", "type": "string", "description": "The credentialId of the credential to remove from the virtual authenticator"}
+            ]
+        },
+        {
+            "name": "removeAllVirtualAuthenticatorCredentials",
+            "description": "Remove all credentials from a given virtual authenticatior for the specified browsing context",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to fetch all credentials for." }
+            ]
+        },
+        {
+            "name": "setVirtualAuthenticatorUserVerified",
+            "description": "set isUserVerified property for a given virtual authenticator for the specified browsing context",
+            "parameters": [
+                { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+                { "name": "authenticatorId", "type": "string", "description": "The virtual authenticator id to fetch all credentials for." },
+                { "name": "isUserVerified", "type": "boolean", "description": "The isUserVerified value to set on the given virtual authenticator"}
+            ]
         }
     ],
     "events": [

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2021-11-04 17:40:39 UTC (rev 285267)
@@ -53,6 +53,11 @@
 #include <wtf/UUID.h>
 #include <wtf/text/StringConcatenate.h>
 
+#if ENABLE(WEB_AUTHN)
+#include "VirtualAuthenticatorManager.h"
+#include <WebCore/AuthenticatorTransport.h>
+#endif // ENABLE(WEB_AUTHN)
+
 namespace WebKit {
 
 using namespace Inspector;
@@ -1530,6 +1535,105 @@
     return { };
 }
 
+#if ENABLE(WEB_AUTHN)
+static WebCore::AuthenticatorTransport toAuthenticatorTransport(Inspector::Protocol::Automation::AuthenticatorTransport transport)
+{
+    switch (transport) {
+    case Inspector::Protocol::Automation::AuthenticatorTransport::Usb:
+        return WebCore::AuthenticatorTransport::Usb;
+    case Inspector::Protocol::Automation::AuthenticatorTransport::Nfc:
+        return WebCore::AuthenticatorTransport::Nfc;
+    case Inspector::Protocol::Automation::AuthenticatorTransport::Ble:
+        return WebCore::AuthenticatorTransport::Ble;
+    case Inspector::Protocol::Automation::AuthenticatorTransport::Internal:
+        return WebCore::AuthenticatorTransport::Internal;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebCore::AuthenticatorTransport::Internal;
+    }
+}
+#endif // ENABLE(WEB_AUTHN)
+
+Inspector::Protocol::ErrorStringOr<String /* authenticatorId */> WebAutomationSession::addVirtualAuthenticator(const String& browsingContextHandle, Ref<JSON::Object>&& authenticator)
+{
+#if ENABLE(WEB_AUTHN)
+    auto protocol = authenticator->getString("protocol"_s);
+    if (!protocol)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'protocol' is missing or invalid.");
+    auto transport = authenticator->getString("transport"_s);
+    if (!transport)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'transport' is missing or invalid.");
+    auto parsedTransport = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::AuthenticatorTransport>(transport);
+    if (!parsedTransport)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'transport' has an unknown value.");
+    auto hasResidentKey = authenticator->getBoolean("hasResidentKey"_s);
+    if (!hasResidentKey)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'hasResidentKey' is missing or invalid.");
+    auto hasUserVerification = authenticator->getBoolean("hasUserVerification"_s);
+    if (!hasUserVerification)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'hasUserVerification' is missing or invalid.");
+    auto isUserConsenting = authenticator->getBoolean("isUserConsenting"_s);
+    if (!isUserConsenting)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'isUserConsenting' is missing or invalid.");
+    auto isUserVerified = authenticator->getBoolean("isUserVerified"_s);
+    if (!isUserVerified)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'isUserVerified' is missing or invalid.");
+
+    auto page = webPageProxyForHandle(browsingContextHandle);
+    if (!page)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
+    return page->websiteDataStore().virtualAuthenticatorManager().createAuthenticator({
+        .protocol = protocol,
+        .transport = toAuthenticatorTransport(parsedTransport.value()),
+        .hasResidentKey = *hasResidentKey,
+        .hasUserVerification = *hasUserVerification,
+        .isUserConsenting = *isUserConsenting,
+        .isUserVerified = *isUserVerified,
+    });
+#else
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+#endif // ENABLE(WEB_AUTHN)
+}
+
+Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::removeVirtualAuthenticator(const String& browsingContextHandle, const String& authenticatorId)
+{
+#if ENABLE(WEB_AUTHN)
+    auto page = webPageProxyForHandle(browsingContextHandle);
+    if (!page)
+        SYNC_FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
+    if (!page->websiteDataStore().virtualAuthenticatorManager().removeAuthenticator(authenticatorId))
+        SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "No such authenticator exists.");
+    return { };
+#else
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+#endif // ENABLE(WEB_AUTHN)
+}
+
+Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::addVirtualAuthenticatorCredential(const String& browsingContextHandle, const String& authenticatorId, Ref<JSON::Object>&& credential)
+{
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+}
+
+Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::Automation::VirtualAuthenticatorCredential>> /* credentials */> WebAutomationSession::getVirtualAuthenticatorCredentials(const String& browsingContextHandle, const String& authenticatorId)
+{
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+}
+
+Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::removeVirtualAuthenticatorCredential(const String& browsingContextHandle, const String& authenticatorId, const String& credentialId)
+{
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+}
+
+Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::removeAllVirtualAuthenticatorCredentials(const String& browsingContextHandle, const String& authenticatorId)
+{
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+}
+
+Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::setVirtualAuthenticatorUserVerified(const String& browsingContextHandle, const String& authenticatorId, bool isUserVerified)
+{
+    SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(NotImplemented, "This method is not yet implemented.");
+}
+
 bool WebAutomationSession::shouldAllowGetUserMediaForPage(const WebPageProxy&) const
 {
     return m_permissionForGetUserMedia;

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -204,6 +204,14 @@
     Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::Automation::SessionPermissionData>>> getSessionPermissions();
     Inspector::Protocol::ErrorStringOr<void> setSessionPermissions(Ref<JSON::Array>&&);
 
+    Inspector::Protocol::ErrorStringOr<String /* authenticatorId */> addVirtualAuthenticator(const String& browsingContextHandle, Ref<JSON::Object>&& authenticator);
+    Inspector::Protocol::ErrorStringOr<void> removeVirtualAuthenticator(const String& browsingContextHandle, const String& authenticatorId);
+    Inspector::Protocol::ErrorStringOr<void> addVirtualAuthenticatorCredential(const String& browsingContextHandle, const String& authenticatorId, Ref<JSON::Object>&& credential);
+    Inspector::Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Inspector::Protocol::Automation::VirtualAuthenticatorCredential>> /* credentials */> getVirtualAuthenticatorCredentials(const String& browsingContextHandle, const String& authenticatorId);
+    Inspector::Protocol::ErrorStringOr<void> removeVirtualAuthenticatorCredential(const String& browsingContextHandle, const String& authenticatorId, const String& credentialId);
+    Inspector::Protocol::ErrorStringOr<void> removeAllVirtualAuthenticatorCredentials(const String& browsingContextHandle, const String& authenticatorId);
+    Inspector::Protocol::ErrorStringOr<void> setVirtualAuthenticatorUserVerified(const String& browsingContextHandle, const String& authenticatorId, bool isUserVerified);
+
 #if PLATFORM(MAC)
     void inspectBrowsingContext(const Inspector::Protocol::Automation::BrowsingContextHandle&, std::optional<bool>&& enableAutoCapturing, Ref<InspectBrowsingContextCallback>&&);
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -69,6 +69,7 @@
     void cancel(); // Called from the presenter.
 
     virtual bool isMock() const { return false; }
+    virtual bool isVirtual() const { return false; }
 
     void enableModernWebAuthentication();
     void enableNativeSupport();

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorConfiguration.h (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorConfiguration.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorConfiguration.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include <WebCore/AuthenticatorTransport.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+struct VirtualAuthenticatorConfiguration {
+    WTF_MAKE_STRUCT_FAST_ALLOCATED;
+    // FIXME: use ProtocolVersion here
+    String protocol;
+    WebCore::AuthenticatorTransport transport;
+    bool hasResidentKey;
+    bool hasUserVerification;
+    bool isUserConsenting;
+    bool isUserVerified;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.cpp (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.cpp	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.cpp	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "VirtualAuthenticatorManager.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include <VirtualService.h>
+#include <wtf/UUID.h>
+
+namespace WebKit {
+
+VirtualAuthenticatorManager::VirtualAuthenticatorManager()
+    : AuthenticatorManager()
+{
+}
+
+String VirtualAuthenticatorManager::createAuthenticator(const VirtualAuthenticatorConfiguration& config)
+{
+    if (config.transport != WebCore::AuthenticatorTransport::Internal)
+        UNIMPLEMENTED();
+    auto id = createCanonicalUUIDString();
+    m_virtualAuthenticators.set(id, makeUniqueRef<VirtualAuthenticatorConfiguration>(config));
+
+    return id;
+}
+
+bool VirtualAuthenticatorManager::removeAuthenticator(const String& id)
+{
+    return m_virtualAuthenticators.remove(id);
+}
+
+UniqueRef<AuthenticatorTransportService> VirtualAuthenticatorManager::createService(WebCore::AuthenticatorTransport transport, AuthenticatorTransportService::Observer& observer) const
+{
+    Vector<VirtualAuthenticatorConfiguration> configs;
+    for (auto& config : m_virtualAuthenticators.values()) {
+        if (config.get().transport == transport)
+            configs.append(config.get());
+    }
+    return VirtualService::createVirtual(transport, observer, configs);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.h (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualAuthenticatorManager.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include "AuthenticatorManager.h"
+#include "VirtualAuthenticatorConfiguration.h"
+
+namespace WebKit {
+
+class VirtualAuthenticatorManager final : public AuthenticatorManager {
+public:
+    explicit VirtualAuthenticatorManager();
+
+    String createAuthenticator(const VirtualAuthenticatorConfiguration& /*config/*/);
+    bool removeAuthenticator(const String& /*authenticatorId*/);
+
+    bool isVirtual() const final { return true; }
+
+private:
+    UniqueRef<AuthenticatorTransportService> createService(WebCore::AuthenticatorTransport, AuthenticatorTransportService::Observer&) const final;
+
+    HashMap<String, UniqueRef<VirtualAuthenticatorConfiguration>> m_virtualAuthenticators;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.h (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include "LocalConnection.h"
+#include "VirtualAuthenticatorConfiguration.h"
+#include <wtf/WeakPtr.h>
+
+namespace WebKit {
+struct VirtualAuthenticatorConfiguration;
+
+class VirtualLocalConnection final : public CanMakeWeakPtr<VirtualLocalConnection>, public LocalConnection {
+public:
+    explicit VirtualLocalConnection(const VirtualAuthenticatorConfiguration&);
+
+private:
+    void verifyUser(const String&, WebCore::ClientDataType, SecAccessControlRef, WebCore::UserVerificationRequirement, UserVerificationCallback&&) final;
+    void verifyUser(SecAccessControlRef, LAContext *, CompletionHandler<void(UserVerification)>&&) final;
+    void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const final;
+    void filterResponses(Vector<Ref<WebCore::AuthenticatorAssertionResponse>>&) const final;
+
+    VirtualAuthenticatorConfiguration m_configuration;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.mm (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualLocalConnection.mm	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "VirtualLocalConnection.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#import "VirtualAuthenticatorConfiguration.h"
+#import <_javascript_Core/ArrayBuffer.h>
+#import <Security/SecItem.h>
+#import <WebCore/AuthenticatorAssertionResponse.h>
+#import <WebCore/ExceptionData.h>
+#import <wtf/Ref.h>
+#import <wtf/RunLoop.h>
+#import <wtf/spi/cocoa/SecuritySPI.h>
+#import <wtf/text/Base64.h>
+#import <wtf/text/WTFString.h>
+
+#import "LocalAuthenticationSoftLink.h"
+
+namespace WebKit {
+using namespace WebCore;
+
+VirtualLocalConnection::VirtualLocalConnection(const VirtualAuthenticatorConfiguration& configuration)
+    : m_configuration(configuration)
+{
+}
+
+void VirtualLocalConnection::verifyUser(const String&, ClientDataType, SecAccessControlRef, WebCore::UserVerificationRequirement, UserVerificationCallback&& callback)
+{
+    // Mock async operations.
+    RunLoop::main().dispatch([weakThis = WeakPtr { *this }, callback = WTFMove(callback)]() mutable {
+        if (!weakThis) {
+            callback(UserVerification::No, adoptNS([allocLAContextInstance() init]).get());
+            return;
+        }
+        ASSERT(weakThis->m_configuration.transport == AuthenticatorTransport::Internal);
+
+        UserVerification userVerification = weakThis->m_configuration.isUserVerified ? UserVerification::Yes : UserVerification::No;
+
+        callback(userVerification, adoptNS([allocLAContextInstance() init]).get());
+    });
+}
+
+void VirtualLocalConnection::verifyUser(SecAccessControlRef, LAContext *, CompletionHandler<void(UserVerification)>&& callback)
+{
+    // Mock async operations.
+    RunLoop::main().dispatch([weakThis = WeakPtr { *this }, callback = WTFMove(callback)]() mutable {
+        if (!weakThis) {
+            callback(UserVerification::No);
+            return;
+        }
+        ASSERT(weakThis->m_configuration.transport == AuthenticatorTransport::Internal);
+
+        UserVerification userVerification = weakThis->m_configuration.isUserVerified ? UserVerification::Yes : UserVerification::No;
+
+        callback(userVerification);
+    });
+}
+
+void VirtualLocalConnection::getAttestation(SecKeyRef, NSData *, NSData *, AttestationCallback&& callback) const
+{
+    // Mock async operations.
+    RunLoop::main().dispatch([callback = WTFMove(callback)]() mutable {
+        callback(NULL, [NSError errorWithDomain:@"WebAuthentication" code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"The operation couldn't complete." }]);
+    });
+}
+
+void VirtualLocalConnection::filterResponses(Vector<Ref<AuthenticatorAssertionResponse>>& responses) const
+{
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.h (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include "AuthenticatorTransportService.h"
+#include "VirtualAuthenticatorConfiguration.h"
+
+namespace WebKit {
+
+class VirtualService : public AuthenticatorTransportService {
+public:
+    explicit VirtualService(Observer&, const Vector<VirtualAuthenticatorConfiguration>&);
+
+    static UniqueRef<AuthenticatorTransportService> createVirtual(WebCore::AuthenticatorTransport, Observer&, const Vector<VirtualAuthenticatorConfiguration>& configs);
+private:
+    void startDiscoveryInternal() final;
+
+    Vector<VirtualAuthenticatorConfiguration> m_configurations;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.mm (0 => 285267)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Virtual/VirtualService.mm	2021-11-04 17:40:39 UTC (rev 285267)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "VirtualService.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#import "LocalAuthenticator.h"
+#import "VirtualLocalConnection.h"
+#import <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+VirtualService::VirtualService(Observer& observer, const Vector<VirtualAuthenticatorConfiguration>& configurations)
+    : AuthenticatorTransportService(observer), m_configurations(configurations)
+{
+}
+
+UniqueRef<AuthenticatorTransportService> VirtualService::createVirtual(WebCore::AuthenticatorTransport transport, Observer& observer,  const Vector<VirtualAuthenticatorConfiguration>& configs)
+{
+    return makeUniqueRef<VirtualService>(observer, configs);
+}
+
+void VirtualService::startDiscoveryInternal()
+{
+
+    for (auto& config : m_configurations) {
+        if (!observer())
+            return;
+        switch (config.transport) {
+        case WebCore::AuthenticatorTransport::Internal:
+            observer()->authenticatorAdded(LocalAuthenticator::create(makeUniqueRef<VirtualLocalConnection>(config)));
+                break;
+        default:
+            UNIMPLEMENTED();
+        }
+    }
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-11-04 17:40:39 UTC (rev 285267)
@@ -82,6 +82,10 @@
 #include "DefaultWebBrowserChecks.h"
 #endif
 
+#if ENABLE(WEB_AUTHN)
+#include "VirtualAuthenticatorManager.h"
+#endif // ENABLE(WEB_AUTHN)
+
 namespace WebKit {
 
 static bool allowsWebsiteDataRecordsForAllOrigins;
@@ -1945,6 +1949,13 @@
     }
     static_cast<MockAuthenticatorManager*>(&m_authenticatorManager)->setTestConfiguration(WTFMove(configuration));
 }
+
+VirtualAuthenticatorManager& WebsiteDataStore::virtualAuthenticatorManager()
+{
+    if (!m_authenticatorManager->isVirtual())
+        m_authenticatorManager = makeUniqueRef<VirtualAuthenticatorManager>();
+    return static_cast<VirtualAuthenticatorManager&>(m_authenticatorManager.get());
+}
 #endif
 
 API::HTTPCookieStore& WebsiteDataStore::cookieStore()

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (285266 => 285267)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2021-11-04 17:40:39 UTC (rev 285267)
@@ -87,6 +87,7 @@
 class DeviceIdHashSaltStorage;
 class NetworkProcessProxy;
 class SOAuthorizationCoordinator;
+class VirtualAuthenticatorManager;
 class WebPageProxy;
 class WebProcessPool;
 class WebProcessProxy;
@@ -307,6 +308,7 @@
 #if ENABLE(WEB_AUTHN)
     AuthenticatorManager& authenticatorManager() { return m_authenticatorManager.get(); }
     void setMockWebAuthenticationConfiguration(WebCore::MockWebAuthenticationConfiguration&&);
+    VirtualAuthenticatorManager& virtualAuthenticatorManager();
 #endif
 
     const WebsiteDataStoreConfiguration& configuration() { return m_configuration.get(); }

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (285266 => 285267)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-11-04 16:46:14 UTC (rev 285266)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-11-04 17:40:39 UTC (rev 285267)
@@ -1049,6 +1049,13 @@
 		51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */; };
 		5272D4C91E735F0900EB4290 /* WKProtectionSpaceNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 5272D4C71E735F0900EB4290 /* WKProtectionSpaceNS.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		528C37C1195CBB1A00D8B9CC /* WKBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9F28101958F478008CAC72 /* WKBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		52CDC5C42731DA0D00A3E3EB /* VirtualAuthenticatorConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CDC5BD2731DA0C00A3E3EB /* VirtualAuthenticatorConfiguration.h */; };
+		52CDC5C52731DA0D00A3E3EB /* VirtualService.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52CDC5BE2731DA0C00A3E3EB /* VirtualService.mm */; };
+		52CDC5C62731DA0D00A3E3EB /* VirtualAuthenticatorManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52CDC5BF2731DA0C00A3E3EB /* VirtualAuthenticatorManager.cpp */; };
+		52CDC5C72731DA0D00A3E3EB /* VirtualLocalConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CDC5C02731DA0C00A3E3EB /* VirtualLocalConnection.h */; };
+		52CDC5C82731DA0D00A3E3EB /* VirtualService.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CDC5C12731DA0C00A3E3EB /* VirtualService.h */; };
+		52CDC5C92731DA0D00A3E3EB /* VirtualLocalConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52CDC5C22731DA0C00A3E3EB /* VirtualLocalConnection.mm */; };
+		52CDC5CA2731DA0D00A3E3EB /* VirtualAuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CDC5C32731DA0C00A3E3EB /* VirtualAuthenticatorManager.h */; };
 		52D5A1B01C57495A00DE34A3 /* VideoFullscreenManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1AA1C57494E00DE34A3 /* VideoFullscreenManagerProxy.h */; };
 		52F060E11654318500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52F060DD1654317500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp */; };
 		532159551DBAE7290054AA3C /* NetworkSessionCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 532159501DBAE6D70054AA3C /* NetworkSessionCocoa.h */; };
@@ -4069,6 +4076,13 @@
 		51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkResourceLoader.h; sourceTree = "<group>"; };
 		5272D4C71E735F0900EB4290 /* WKProtectionSpaceNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKProtectionSpaceNS.h; path = mac/WKProtectionSpaceNS.h; sourceTree = "<group>"; };
 		5272D4C81E735F0900EB4290 /* WKProtectionSpaceNS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKProtectionSpaceNS.mm; path = mac/WKProtectionSpaceNS.mm; sourceTree = "<group>"; };
+		52CDC5BD2731DA0C00A3E3EB /* VirtualAuthenticatorConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualAuthenticatorConfiguration.h; sourceTree = "<group>"; };
+		52CDC5BE2731DA0C00A3E3EB /* VirtualService.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VirtualService.mm; sourceTree = "<group>"; };
+		52CDC5BF2731DA0C00A3E3EB /* VirtualAuthenticatorManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VirtualAuthenticatorManager.cpp; sourceTree = "<group>"; };
+		52CDC5C02731DA0C00A3E3EB /* VirtualLocalConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualLocalConnection.h; sourceTree = "<group>"; };
+		52CDC5C12731DA0C00A3E3EB /* VirtualService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualService.h; sourceTree = "<group>"; };
+		52CDC5C22731DA0C00A3E3EB /* VirtualLocalConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VirtualLocalConnection.mm; sourceTree = "<group>"; };
+		52CDC5C32731DA0C00A3E3EB /* VirtualAuthenticatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualAuthenticatorManager.h; sourceTree = "<group>"; };
 		52D5A1AA1C57494E00DE34A3 /* VideoFullscreenManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenManagerProxy.h; sourceTree = "<group>"; };
 		52D5A1AB1C57494E00DE34A3 /* VideoFullscreenManagerProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VideoFullscreenManagerProxy.messages.in; sourceTree = "<group>"; };
 		52D5A1AC1C57494E00DE34A3 /* VideoFullscreenManagerProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFullscreenManagerProxy.mm; sourceTree = "<group>"; };
@@ -8740,6 +8754,20 @@
 			path = ios;
 			sourceTree = "<group>";
 		};
+		52CDC5BC2731DA0C00A3E3EB /* Virtual */ = {
+			isa = PBXGroup;
+			children = (
+				52CDC5BD2731DA0C00A3E3EB /* VirtualAuthenticatorConfiguration.h */,
+				52CDC5BF2731DA0C00A3E3EB /* VirtualAuthenticatorManager.cpp */,
+				52CDC5C32731DA0C00A3E3EB /* VirtualAuthenticatorManager.h */,
+				52CDC5C02731DA0C00A3E3EB /* VirtualLocalConnection.h */,
+				52CDC5C22731DA0C00A3E3EB /* VirtualLocalConnection.mm */,
+				52CDC5C12731DA0C00A3E3EB /* VirtualService.h */,
+				52CDC5BE2731DA0C00A3E3EB /* VirtualService.mm */,
+			);
+			path = Virtual;
+			sourceTree = "<group>";
+		};
 		5506409C240715AA00AAE045 /* graphics */ = {
 			isa = PBXGroup;
 			children = (
@@ -8939,6 +8967,7 @@
 				57DCED9E2148F9D10016B847 /* Cocoa */,
 				57597EBF218184B20037F924 /* fido */,
 				57DCEDBD214C9FA90016B847 /* Mock */,
+				52CDC5BC2731DA0C00A3E3EB /* Virtual */,
 				57DCEDA42149E64A0016B847 /* Authenticator.cpp */,
 				57DCED8B21485BD70016B847 /* Authenticator.h */,
 				57DCED852147363A0016B847 /* AuthenticatorManager.cpp */,
@@ -12335,6 +12364,10 @@
 				2D819BA21862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h in Headers */,
 				2D6CD119189058A500E5A4A0 /* ViewSnapshotStore.h in Headers */,
 				2684055318B86ED60022C38B /* ViewUpdateDispatcherMessages.h in Headers */,
+				52CDC5C42731DA0D00A3E3EB /* VirtualAuthenticatorConfiguration.h in Headers */,
+				52CDC5CA2731DA0D00A3E3EB /* VirtualAuthenticatorManager.h in Headers */,
+				52CDC5C72731DA0D00A3E3EB /* VirtualLocalConnection.h in Headers */,
+				52CDC5C82731DA0D00A3E3EB /* VirtualService.h in Headers */,
 				2684054418B85A630022C38B /* VisibleContentRectUpdateInfo.h in Headers */,
 				2DD5A7291EBF08D5009BA597 /* VisibleWebPageCounter.h in Headers */,
 				3155EE0D2673F4F00085E59A /* VisionKitSPI.h in Headers */,
@@ -14390,6 +14423,9 @@
 				2D1B5D5D185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp in Sources */,
 				2D819BA11862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp in Sources */,
 				2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */,
+				52CDC5C62731DA0D00A3E3EB /* VirtualAuthenticatorManager.cpp in Sources */,
+				52CDC5C92731DA0D00A3E3EB /* VirtualLocalConnection.mm in Sources */,
+				52CDC5C52731DA0D00A3E3EB /* VirtualService.mm in Sources */,
 				1A60224C18C16B9F00C3E8C9 /* VisitedLinkStoreMessageReceiver.cpp in Sources */,
 				1A8E7D3C18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp in Sources */,
 				57DCED702142EE680016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to