Diff
Modified: trunk/Source/WebCore/ChangeLog (251761 => 251762)
--- trunk/Source/WebCore/ChangeLog 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebCore/ChangeLog 2019-10-30 02:50:31 UTC (rev 251762)
@@ -1,3 +1,16 @@
+2019-10-29 Jiewen Tan <[email protected]>
+
+ [WebAuthn] Add more information to _WKWebAuthenticationPanel
+ https://bugs.webkit.org/show_bug.cgi?id=202561
+ <rdar://problem/55973910>
+
+ Reviewed by Youenn Fablet and Brent Fulgham.
+
+ Covered by new tests within existing test files.
+
+ * Modules/webauthn/AuthenticatorCoordinator.cpp:
+ * Modules/webauthn/WebAuthenticationConstants.h:
+
2019-10-29 Wenson Hsieh <[email protected]>
REGRESSION (r251693): [iOS] Unable to change selection after focusing an element with keyboard attached
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp (251761 => 251762)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp 2019-10-30 02:50:31 UTC (rev 251762)
@@ -42,6 +42,7 @@
#include "RegistrableDomain.h"
#include "LegacySchemeRegistry.h"
#include "SecurityOrigin.h"
+#include "WebAuthenticationConstants.h"
#include <pal/crypto/CryptoDigest.h>
#include <wtf/JSONValues.h>
#include <wtf/NeverDestroyed.h>
@@ -51,11 +52,6 @@
namespace AuthenticatorCoordinatorInternal {
-enum class ClientDataType {
- Create,
- Get
-};
-
// FIXME(181948): Add token binding ID.
static Ref<ArrayBuffer> produceClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin)
{
Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (251761 => 251762)
--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -70,4 +70,10 @@
// https://www.w3.org/TR/webauthn/#none-attestation
const char noneAttestationValue[] = "none";
+// https://www.w3.org/TR/webauthn-1/#dom-collectedclientdata-type
+enum class ClientDataType : bool {
+ Create,
+ Get
+};
+
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (251761 => 251762)
--- trunk/Source/WebKit/ChangeLog 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/ChangeLog 2019-10-30 02:50:31 UTC (rev 251762)
@@ -1,3 +1,62 @@
+2019-10-29 Jiewen Tan <[email protected]>
+
+ [WebAuthn] Add more information to _WKWebAuthenticationPanel
+ https://bugs.webkit.org/show_bug.cgi?id=202561
+ <rdar://problem/55973910>
+
+ Reviewed by Youenn Fablet and Brent Fulgham.
+
+ This change adds transports and type to _WKWebAuthenticationPanel such that
+ clients can know what transport the current ceremony demands and the type of
+ the current ceremony. These extra information allow clients to give users
+ more specific instructions to interact with authenticators.
+
+ To pass transports to client, the way how them is collected is changed significantly:
+ 1) The timing is moved to runPanel before the client delegate call.
+ 2) NfcService::isAvailable is added for AuthenticatorManager to determine if NFC
+ is available in the current device.
+ 3) AuthenticatorManager::filterTransports is added to filter transports requested
+ by RP to ones that are available. This process is handled by each service naturally
+ before.
+ 4) AuthenticatorManager::startRequest is now being splitted into AuthenticatorManager::handleRequest,
+ AuthenticatorManager::runPanel and AuthenticatorManager::getTransports.
+
+ To pass type to _WKWebAuthenticationPanel, ClientDataType is moved from
+ WebCore::AuthenticatorCoordinator to WebCore::WebAuthenticationConstants in
+ order to be reused to indicate the ceremony type.
+
+ * UIProcess/API/APIWebAuthenticationPanel.cpp:
+ (API::WebAuthenticationPanel::create):
+ (API::WebAuthenticationPanel::WebAuthenticationPanel):
+ * UIProcess/API/APIWebAuthenticationPanel.h:
+ * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
+ * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
+ (-[_WKWebAuthenticationPanel relyingPartyID]):
+ (wkWebAuthenticationTransport):
+ (-[_WKWebAuthenticationPanel transports]):
+ (wkWebAuthenticationType):
+ (-[_WKWebAuthenticationPanel type]):
+ * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
+ (WebKit::WebCore::collectTransports):
+ (WebKit::WebCore::getClientDataType):
+ (WebKit::AuthenticatorManager::handleRequest):
+ (WebKit::AuthenticatorManager::filterTransports const):
+ (WebKit::AuthenticatorManager::startDiscovery):
+ (WebKit::AuthenticatorManager::initTimeOutTimer):
+ (WebKit::AuthenticatorManager::runPanel):
+ (WebKit::AuthenticatorManager::getTransports const):
+ (WebKit::AuthenticatorManager::respondReceivedInternal): Deleted.
+ (WebKit::AuthenticatorManager::startRequest): Deleted.
+ * UIProcess/WebAuthentication/AuthenticatorManager.h:
+ (WebKit::AuthenticatorManager::respondReceivedInternal):
+ * UIProcess/WebAuthentication/Cocoa/NfcService.h:
+ * UIProcess/WebAuthentication/Cocoa/NfcService.mm:
+ (WebKit::NfcService::isAvailable):
+ (WebKit::NfcService::platformStartDiscovery):
+ * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:
+ (WebKit::MockAuthenticatorManager::filterTransports const):
+ * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h:
+
2019-10-29 Wenson Hsieh <[email protected]>
REGRESSION (r251693): [iOS] Unable to change selection in a focused element if the element's bounds change
Modified: trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.cpp (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.cpp 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.cpp 2019-10-30 02:50:31 UTC (rev 251762)
@@ -30,20 +30,29 @@
#include "APIWebAuthenticationPanelClient.h"
#include "AuthenticatorManager.h"
+#include <WebCore/WebAuthenticationConstants.h>
namespace API {
+using namespace WebCore;
using namespace WebKit;
-Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId)
+Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type)
{
- return adoptRef(*new WebAuthenticationPanel(manager, rpId));
+ return adoptRef(*new WebAuthenticationPanel(manager, rpId, transports, type));
}
-WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId)
+WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type)
: m_manager(makeWeakPtr(manager))
, m_rpId(rpId)
, m_client(WTF::makeUniqueRef<WebAuthenticationPanelClient>())
+ , m_clientDataType(type)
{
+ m_transports = Vector<AuthenticatorTransport>();
+ m_transports.reserveInitialCapacity(AuthenticatorManager::maxTransportNumber);
+ if (transports.contains(AuthenticatorTransport::Usb))
+ m_transports.uncheckedAppend(AuthenticatorTransport::Usb);
+ if (transports.contains(AuthenticatorTransport::Nfc))
+ m_transports.uncheckedAppend(AuthenticatorTransport::Nfc);
}
WebAuthenticationPanel::~WebAuthenticationPanel() = default;
Modified: trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.h (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -28,10 +28,15 @@
#if ENABLE(WEB_AUTHN)
#include "APIObject.h"
+#include <WebCore/AuthenticatorTransport.h>
#include <wtf/UniqueRef.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
+namespace WebCore {
+enum class ClientDataType : bool;
+}
+
namespace WebKit {
class AuthenticatorManager;
}
@@ -42,10 +47,14 @@
class WebAuthenticationPanel final : public ObjectImpl<Object::Type::WebAuthenticationPanel>, public CanMakeWeakPtr<WebAuthenticationPanel> {
public:
- static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId);
+ using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
+
+ static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
~WebAuthenticationPanel();
WTF::String rpId() const { return m_rpId; }
+ const Vector<WebCore::AuthenticatorTransport>& transports() const { return m_transports; }
+ WebCore::ClientDataType clientDataType() const { return m_clientDataType; }
void cancel() const;
const WebAuthenticationPanelClient& client() const { return m_client.get(); }
@@ -52,11 +61,13 @@
void setClient(UniqueRef<WebAuthenticationPanelClient>&&);
private:
- WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId);
+ WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
WeakPtr<WebKit::AuthenticatorManager> m_manager;
WTF::String m_rpId;
UniqueRef<WebAuthenticationPanelClient> m_client;
+ Vector<WebCore::AuthenticatorTransport> m_transports;
+ WebCore::ClientDataType m_clientDataType;
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -49,6 +49,16 @@
_WKWebAuthenticationResultFailed,
} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+typedef NS_ENUM(NSInteger, _WKWebAuthenticationTransport) {
+ _WKWebAuthenticationTransportUSB,
+ _WKWebAuthenticationTransportNFC,
+} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+typedef NS_ENUM(NSInteger, _WKWebAuthenticationType) {
+ _WKWebAuthenticationTypeCreate,
+ _WKWebAuthenticationTypeGet,
+} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
@protocol _WKWebAuthenticationPanelDelegate <NSObject>
@optional
@@ -63,6 +73,8 @@
@property (nullable, nonatomic, weak) id <_WKWebAuthenticationPanelDelegate> delegate;
@property (nonatomic, readonly, copy) NSString *relyingPartyID;
+@property (nonatomic, readonly, copy) NSArray *transports;
+@property (nonatomic, readonly) _WKWebAuthenticationType type;
- (void)cancel;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2019-10-30 02:50:31 UTC (rev 251762)
@@ -26,6 +26,7 @@
#import "config.h"
#import "WebAuthenticationPanelClient.h"
#import "_WKWebAuthenticationPanelInternal.h"
+#import <WebCore/WebAuthenticationConstants.h>
#import <wtf/RetainPtr.h>
@@ -32,6 +33,7 @@
@implementation _WKWebAuthenticationPanel {
#if ENABLE(WEB_AUTHN)
WeakPtr<WebKit::WebAuthenticationPanelClient> _client;
+ RetainPtr<NSMutableArray> _transports;
#endif
}
@@ -44,11 +46,6 @@
[super dealloc];
}
-- (NSString *)relyingPartyID
-{
- return _panel->rpId();
-}
-
- (id <_WKWebAuthenticationPanelDelegate>)delegate
{
if (!_client)
@@ -63,6 +60,55 @@
_panel->setClient(WTFMove(client));
}
+
+- (NSString *)relyingPartyID
+{
+ return _panel->rpId();
+}
+
+static _WKWebAuthenticationTransport wkWebAuthenticationTransport(WebCore::AuthenticatorTransport transport)
+{
+ switch (transport) {
+ case WebCore::AuthenticatorTransport::Usb:
+ return _WKWebAuthenticationTransportUSB;
+ case WebCore::AuthenticatorTransport::Nfc:
+ return _WKWebAuthenticationTransportNFC;
+ default:
+ ASSERT_NOT_REACHED();
+ return _WKWebAuthenticationTransportUSB;
+ }
+}
+
+- (NSArray *)transports
+{
+ if (_transports)
+ return _transports.get();
+
+ auto& transports = _panel->transports();
+ _transports = [[NSMutableArray alloc] initWithCapacity:transports.size()];
+ for (auto& transport : transports)
+ [_transports addObject:adoptNS([[NSNumber alloc] initWithInt:wkWebAuthenticationTransport(transport)]).get()];
+ return _transports.get();
+}
+
+static _WKWebAuthenticationType wkWebAuthenticationType(WebCore::ClientDataType type)
+{
+ switch (type) {
+ case WebCore::ClientDataType::Create:
+ return _WKWebAuthenticationTypeCreate;
+ case WebCore::ClientDataType::Get:
+ return _WKWebAuthenticationTypeGet;
+ default:
+ ASSERT_NOT_REACHED();
+ return _WKWebAuthenticationTypeCreate;
+ }
+}
+
+- (_WKWebAuthenticationType)type
+{
+ return wkWebAuthenticationType(_panel->clientDataType());
+}
+
#endif // ENABLE(WEB_AUTHN)
- (void)cancel
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp 2019-10-30 02:50:31 UTC (rev 251762)
@@ -31,10 +31,13 @@
#include "APIUIClient.h"
#include "APIWebAuthenticationPanel.h"
#include "APIWebAuthenticationPanelClient.h"
+#include "LocalService.h"
+#include "NfcService.h"
#include "WebPageProxy.h"
#include "WebPreferencesKeys.h"
#include <WebCore/AuthenticatorTransport.h>
#include <WebCore/PublicKeyCredentialCreationOptions.h>
+#include <WebCore/WebAuthenticationConstants.h>
#include <wtf/MonotonicTime.h>
namespace WebKit {
@@ -42,8 +45,6 @@
namespace {
-const size_t maxTransportNumber = 3;
-
// Suggested by WebAuthN spec as of 7 August 2018.
const unsigned maxTimeOutValue = 120000;
@@ -108,12 +109,12 @@
if (transport == AuthenticatorTransport::Ble)
continue;
result.add(transport);
- if (result.size() >= maxTransportNumber)
+ if (result.size() >= AuthenticatorManager::maxTransportNumber)
return result;
}
}
- ASSERT(result.size() < maxTransportNumber);
+ ASSERT(result.size() < AuthenticatorManager::maxTransportNumber);
return result;
}
@@ -141,8 +142,17 @@
return WTF::get<PublicKeyCredentialRequestOptions>(options).rpId;
}
+static ClientDataType getClientDataType(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options)
+{
+ if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options))
+ return ClientDataType::Create;
+ return ClientDataType::Get;
+}
+
} // namespace
+const size_t AuthenticatorManager::maxTransportNumber = 3;
+
AuthenticatorManager::AuthenticatorManager()
: m_requestTimeOutTimer(RunLoop::main(), this, &AuthenticatorManager::timeOutTimerFired)
{
@@ -161,6 +171,7 @@
m_pendingCompletionHandler = WTFMove(callback);
// 2. Ask clients to show appropriate UI if any and then start the request.
+ initTimeOutTimer();
runPanel();
}
@@ -261,16 +272,19 @@
return AuthenticatorTransportService::create(transport, observer);
}
-void AuthenticatorManager::respondReceivedInternal(Respond&&)
+void AuthenticatorManager::filterTransports(TransportSet& transports) const
{
+ if (!NfcService::isAvailable())
+ transports.remove(AuthenticatorTransport::Nfc);
+ if (!LocalService::isAvailable())
+ transports.remove(AuthenticatorTransport::Internal);
}
void AuthenticatorManager::startDiscovery(const TransportSet& transports)
{
+ ASSERT(RunLoop::isMain());
ASSERT(m_services.isEmpty() && transports.size() <= maxTransportNumber);
for (auto& transport : transports) {
- if (transport == AuthenticatorTransport::Internal && !isFeatureEnabled(m_pendingRequestData.page.get(), WebPreferencesKey::webAuthenticationLocalAuthenticatorEnabledKey()))
- continue;
// Only allow USB authenticators when clients don't have dedicated UI.
if (transport != AuthenticatorTransport::Usb && (m_pendingRequestData.panelResult == WebAuthenticationPanelResult::Unavailable))
continue;
@@ -280,8 +294,15 @@
}
}
-void AuthenticatorManager::initTimeOutTimer(const Optional<unsigned>& timeOutInMs)
+void AuthenticatorManager::initTimeOutTimer()
{
+ Optional<unsigned> timeOutInMs;
+ WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) {
+ timeOutInMs = options.timeout;
+ }, [&](const PublicKeyCredentialRequestOptions& options) {
+ timeOutInMs = options.timeout;
+ });
+
unsigned timeOutInMsValue = std::min(maxTimeOutValue, timeOutInMs.valueOr(maxTimeOutValue));
m_requestTimeOutTimer.startOneShot(Seconds::fromMilliseconds(timeOutInMsValue));
}
@@ -303,9 +324,12 @@
if (!frame)
return;
- m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(m_pendingRequestData.options));
+ // Get available transports and start discovering authenticators on them.
+ auto& options = m_pendingRequestData.options;
+ auto transports = getTransports();
+ m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(options), transports, getClientDataType(options));
auto& panel = *m_pendingRequestData.panel;
- page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, m_pendingRequestData.origin, [weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {
+ page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, m_pendingRequestData.origin, [transports = WTFMove(transports), weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {
// The panel address is used to determine if the current pending request is still the same.
if (!weakThis || !weakPanel
|| (result == WebAuthenticationPanelResult::DidNotPresent)
@@ -312,32 +336,16 @@
|| (weakPanel.get() != m_pendingRequestData.panel.get()))
return;
m_pendingRequestData.panelResult = result;
- startRequest();
+ startDiscovery(transports);
});
}
-void AuthenticatorManager::startRequest()
-{
- ASSERT(RunLoop::isMain());
- // Get available transports and start discovering authenticators on them.
- WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) {
- initTimeOutTimer(options.timeout);
-
- auto transports = collectTransports(options.authenticatorSelection);
- processGoogleLegacyAppIdSupportExtension(options.extensions, transports);
- startDiscovery(collectTransports(options.authenticatorSelection));
- }, [&](const PublicKeyCredentialRequestOptions& options) {
- initTimeOutTimer(options.timeout);
- startDiscovery(collectTransports(options.allowCredentials));
- });
-}
-
void AuthenticatorManager::invokePendingCompletionHandler(Respond&& respond)
{
if (auto *panel = m_pendingRequestData.panel.get()) {
WTF::switchOn(respond, [&](const WebCore::PublicKeyCredentialData&) {
panel->client().dismissPanel(WebAuthenticationResult::Succeeded);
- }, [&](const WebCore::ExceptionData&) {
+ }, [&](const WebCore::ExceptionData&) {
panel->client().dismissPanel(WebAuthenticationResult::Failed);
});
}
@@ -358,6 +366,21 @@
service->restartDiscovery();
}
+auto AuthenticatorManager::getTransports() const -> TransportSet
+{
+ TransportSet transports;
+ WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) {
+ transports = collectTransports(options.authenticatorSelection);
+ processGoogleLegacyAppIdSupportExtension(options.extensions, transports);
+ }, [&](const PublicKeyCredentialRequestOptions& options) {
+ transports = collectTransports(options.allowCredentials);
+ });
+ if (!isFeatureEnabled(m_pendingRequestData.page.get(), WebPreferencesKey::webAuthenticationLocalAuthenticatorEnabledKey()))
+ transports.remove(AuthenticatorTransport::Internal);
+ filterTransports(transports);
+ return transports;
+}
+
} // namespace WebKit
#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -55,6 +55,8 @@
using AuthenticatorTransportService::Observer::weakPtrFactory;
using WeakValueType = AuthenticatorTransportService::Observer::WeakValueType;
+ const static size_t maxTransportNumber;
+
AuthenticatorManager();
virtual ~AuthenticatorManager() = default;
@@ -83,15 +85,16 @@
// Overriden by MockAuthenticatorManager.
virtual UniqueRef<AuthenticatorTransportService> createService(WebCore::AuthenticatorTransport, AuthenticatorTransportService::Observer&) const;
// Overriden to return every exception for tests to confirm.
- virtual void respondReceivedInternal(Respond&&);
+ virtual void respondReceivedInternal(Respond&&) { }
+ virtual void filterTransports(TransportSet&) const;
void startDiscovery(const TransportSet&);
- void initTimeOutTimer(const Optional<unsigned>& timeOutInMs);
+ void initTimeOutTimer();
void timeOutTimerFired();
void runPanel();
- void startRequest();
void resetState();
void restartDiscovery();
+ TransportSet getTransports() const;
// Request: We only allow one request per time. A new request will cancel any pending ones.
WebAuthenticationRequestData m_pendingRequestData;
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -41,6 +41,8 @@
explicit NfcService(Observer&);
~NfcService();
+ static bool isAvailable();
+
// For NfcConnection.
void didConnectTag();
void didDetectMultipleTags() const;
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm 2019-10-30 02:50:31 UTC (rev 251762)
@@ -49,6 +49,15 @@
{
}
+bool NfcService::isAvailable()
+{
+#if HAVE(NEAR_FIELD)
+ return [[getNFHardwareManagerClass() sharedHardwareManager] areFeaturesSupported:NFFeatureReaderMode outError:nil];
+#else
+ return false;
+#endif
+}
+
void NfcService::didConnectTag()
{
#if HAVE(NEAR_FIELD)
@@ -88,7 +97,7 @@
void NfcService::platformStartDiscovery()
{
#if HAVE(NEAR_FIELD)
- if (![[getNFHardwareManagerClass() sharedHardwareManager] areFeaturesSupported:NFFeatureReaderMode outError:nil])
+ if (!isAvailable())
return;
// Will be executed in a different thread.
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp 2019-10-30 02:50:31 UTC (rev 251762)
@@ -50,6 +50,14 @@
requestTimeOutTimer().stop();
}
+void MockAuthenticatorManager::filterTransports(TransportSet& transports) const
+{
+ if (!m_testConfiguration.nfc)
+ transports.remove(AuthenticatorTransport::Nfc);
+ if (!m_testConfiguration.local)
+ transports.remove(AuthenticatorTransport::Internal);
+}
+
} // namespace WebKit
#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h (251761 => 251762)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h 2019-10-30 02:50:31 UTC (rev 251762)
@@ -42,6 +42,7 @@
private:
UniqueRef<AuthenticatorTransportService> createService(WebCore::AuthenticatorTransport, AuthenticatorTransportService::Observer&) const final;
void respondReceivedInternal(Respond&&) final;
+ void filterTransports(TransportSet&) const;
WebCore::MockWebAuthenticationConfiguration m_testConfiguration;
};
Modified: trunk/Tools/ChangeLog (251761 => 251762)
--- trunk/Tools/ChangeLog 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Tools/ChangeLog 2019-10-30 02:50:31 UTC (rev 251762)
@@ -1,3 +1,20 @@
+2019-10-29 Jiewen Tan <[email protected]>
+
+ [WebAuthn] Add more information to _WKWebAuthenticationPanel
+ https://bugs.webkit.org/show_bug.cgi?id=202561
+ <rdar://problem/55973910>
+
+ Reviewed by Youenn Fablet and Brent Fulgham.
+
+ Adds new API tests.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+ (-[TestWebAuthenticationPanelUIDelegate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]):
+ (-[TestWebAuthenticationPanelUIDelegate panel]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/web-authentication-make-credential-hid.html: Added.
+
2019-10-07 Jer Noble <[email protected]>
Implement the Remote Playback API.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (251761 => 251762)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-10-30 02:50:31 UTC (rev 251762)
@@ -351,7 +351,8 @@
579651E7216BFDED006EBFE5 /* FidoHidMessageTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 579651E6216BFD53006EBFE5 /* FidoHidMessageTest.cpp */; };
5797FE311EB15A6800B2F4A0 /* NavigationClientDefaultCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */; };
5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */; };
- 5798337C235EB689008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */; };
+ 5798337E236019A4008E5547 /* web-authentication-make-credential-hid.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */; };
+ 579833922368FA37008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */; };
57A79857224AB34E00A7F6F1 /* WebCryptoMasterKey.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */; };
57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */; };
57C6244E2346BCFA00383FE7 /* _WKWebAuthenticationPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57C6244D2346BCFA00383FE7 /* _WKWebAuthenticationPanel.mm */; };
@@ -1456,10 +1457,12 @@
57663DF32357E48900E85E09 /* web-authentication-get-assertion-hid-cancel.html in Copy Resources */,
577454D02359B378008E1ED7 /* web-authentication-get-assertion-hid-no-credentials.html in Copy Resources */,
57663DEC234F1F9300E85E09 /* web-authentication-get-assertion-hid.html in Copy Resources */,
+ 579833922368FA37008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */,
5798337C235EB689008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */,
57663DEA234EA66D00E85E09 /* web-authentication-get-assertion-nfc.html in Copy Resources */,
577454D22359BB01008E1ED7 /* web-authentication-get-assertion-u2f-no-credentials.html in Copy Resources */,
57C624502346C21E00383FE7 /* web-authentication-get-assertion.html in Copy Resources */,
+ 5798337E236019A4008E5547 /* web-authentication-make-credential-hid.html in Copy Resources */,
1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */,
51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */,
51714EB51CF8C78C004723C4 /* WebProcessKillIDBCleanup-2.html in Copy Resources */,
@@ -1894,6 +1897,7 @@
5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationClientDefaultCrypto.cpp; sourceTree = "<group>"; };
5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "navigation-client-default-crypto.html"; sourceTree = "<group>"; };
5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "web-authentication-get-assertion-nfc-multiple-tags.html"; sourceTree = "<group>"; };
+ 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "web-authentication-make-credential-hid.html"; sourceTree = "<group>"; };
5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProvisionalURLNotChange.mm; sourceTree = "<group>"; };
57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCryptoMasterKey.mm; sourceTree = "<group>"; };
57C6244D2346BCFA00383FE7 /* _WKWebAuthenticationPanel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKWebAuthenticationPanel.mm; sourceTree = "<group>"; };
@@ -3423,6 +3427,7 @@
57663DE9234EA60B00E85E09 /* web-authentication-get-assertion-nfc.html */,
577454D12359BAD5008E1ED7 /* web-authentication-get-assertion-u2f-no-credentials.html */,
57C6244F2346C1EC00383FE7 /* web-authentication-get-assertion.html */,
+ 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */,
51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */,
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (251761 => 251762)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm 2019-10-30 02:48:45 UTC (rev 251761)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm 2019-10-30 02:50:31 UTC (rev 251762)
@@ -44,7 +44,6 @@
static bool webAuthenticationPanelSucceded = false;
static bool webAuthenticationPanelUpdateMultipleNFCTagsPresent = false;
static bool webAuthenticationPanelUpdateNoCredentialsFound = false;
-static RetainPtr<_WKWebAuthenticationPanel> gPanel;
@interface TestWebAuthenticationPanelDelegate : NSObject <_WKWebAuthenticationPanelDelegate>
@end
@@ -97,6 +96,7 @@
RetainPtr<NSObject<_WKWebAuthenticationPanelDelegate>> _delegate;
BlockPtr<void(_WKWebAuthenticationPanelResult)> _callback;
RetainPtr<WKFrameInfo> _frameInfo;
+ RetainPtr<_WKWebAuthenticationPanel> _panel;
}
- (instancetype)init
@@ -121,11 +121,9 @@
_delegate = adoptNS([[TestWebAuthenticationPanelFakeDelegate alloc] init]);
}
ASSERT_NE(panel, nil);
- gPanel = panel;
- [gPanel setDelegate:_delegate.get()];
+ _panel = panel;
+ [_panel setDelegate:_delegate.get()];
- EXPECT_TRUE([[gPanel relyingPartyID] isEqual:@""] || [[gPanel relyingPartyID] isEqual:@"localhost"]);
-
if (_isRacy) {
if (!_callback) {
_callback = makeBlockPtr(completionHandler);
@@ -141,6 +139,11 @@
return _frameInfo.get();
}
+- (_WKWebAuthenticationPanel *)panel
+{
+ return _panel.get();
+}
+
@end
namespace TestWebKitAPI {
@@ -186,9 +189,29 @@
webAuthenticationPanelRan = false;
webAuthenticationPanelFailed = false;
webAuthenticationPanelSucceded = false;
- gPanel = nullptr;
}
+static void checkPanel(_WKWebAuthenticationPanel *panel, NSString *relyingPartyID, NSArray *transports, _WKWebAuthenticationType type)
+{
+ EXPECT_WK_STREQ(panel.relyingPartyID, relyingPartyID);
+
+ // Brute force given the maximum size of the array is 4.
+ auto *theTransports = panel.transports;
+ EXPECT_EQ(theTransports.count, transports.count);
+ size_t count = 0;
+ for (NSNumber *transport : transports) {
+ for (NSNumber *theTransport : theTransports) {
+ if (transport == theTransport) {
+ count++;
+ break;
+ }
+ }
+ }
+ EXPECT_EQ(count, transports.count);
+
+ EXPECT_EQ(panel.type, type);
+}
+
static void checkFrameInfo(WKFrameInfo *frame, bool isMainFrame, NSString *url, NSString *protocol, NSString *host, int port, WKWebView *webView)
{
EXPECT_EQ(frame.mainFrame, isMainFrame);
@@ -244,7 +267,7 @@
Util::run(&webAuthenticationPanelFailed);
}
-TEST(WebAuthenticationPanel, PanelHidSuccess)
+TEST(WebAuthenticationPanel, PanelHidSuccess1)
{
reset();
RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"web-authentication-get-assertion-hid" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
@@ -262,8 +285,29 @@
// A bit of extra checks.
checkFrameInfo([delegate frame], true, [testURL absoluteString], @"file", @"", 0, webView.get());
+ checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeGet);
}
+TEST(WebAuthenticationPanel, PanelHidSuccess2)
+{
+ reset();
+ RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"web-authentication-make-credential-hid" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+ auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
+ [[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
+ [webView setUIDelegate:delegate.get()];
+
+ [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+ Util::run(&webAuthenticationPanelRan);
+ Util::run(&webAuthenticationPanelSucceded);
+
+ // A bit of extra checks.
+ checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeCreate);
+}
+
#if HAVE(NEAR_FIELD)
// This test aims to see if the callback for the first ceremony could affect the second one.
// Therefore, the first callback will be held to return at the time when the second arrives.
@@ -286,6 +330,9 @@
Util::run(&webAuthenticationPanelRan);
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Succeeded!"];
+
+ // A bit of extra checks.
+ checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportNFC]).get()], _WKWebAuthenticationTypeGet);
}
// Unlike the previous one, this one focuses on the order of the delegate callbacks.
@@ -448,6 +495,7 @@
// A bit of extra checks.
checkFrameInfo([delegate frame], false, (id)makeString(url, "/iFrame.html"), @"http", @"localhost", port, webView.get());
+ checkPanel([delegate panel], @"localhost", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeGet);
}
TEST(WebAuthenticationPanel, SubFrameDestructionHidCancel)
@@ -501,7 +549,7 @@
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
- [gPanel cancel];
+ [[delegate panel] cancel];
[webView waitForMessage:@"Operation timed out."];
EXPECT_FALSE(webAuthenticationPanelFailed);
EXPECT_FALSE(webAuthenticationPanelSucceded);
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/web-authentication-make-credential-hid.html (0 => 251762)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/web-authentication-make-credential-hid.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/web-authentication-make-credential-hid.html 2019-10-30 02:50:31 UTC (rev 251762)
@@ -0,0 +1,47 @@
+<input type="text" id="input">
+<script>
+ const testCreationMessageBase64 =
+ "AKMBZnBhY2tlZAJYxEbMf7lnnVWy25CS4cjZ5eHQK3WA8LSBLHcJYuHkj1rYQQAA" +
+ "AE74oBHzjApNFYAGFxEfntx9AEAoCK3O6P5OyXN6V/f+9nAga0NA2Cgp4V3mgSJ5" +
+ "jOHLMDrmxp/S0rbD+aihru1C0aAN3BkiM6GNy5nSlDVqOgTgpQECAyYgASFYIEFb" +
+ "he3RkNud6sgyraBGjlh1pzTlCZehQlL/b18HZ6WGIlggJgfUd/en9p5AIqMQbUni" +
+ "nEeXdFLkvW0/zV5BpEjjNxADo2NhbGcmY3NpZ1hHMEUCIQDKg+ZBmEBtf0lWq4Re" +
+ "dH4/i/LOYqOR4uR2NAj2zQmw9QIgbTXb4hvFbj4T27bv/rGrc+y+0puoYOBkBk9P" +
+ "mCewWlNjeDVjgVkCwjCCAr4wggGmoAMCAQICBHSG/cIwDQYJKoZIhvcNAQELBQAw" +
+ "LjEsMCoGA1UEAxMjWXViaWNvIFUyRiBSb290IENBIFNlcmlhbCA0NTcyMDA2MzEw" +
+ "IBcNMTQwODAxMDAwMDAwWhgPMjA1MDA5MDQwMDAwMDBaMG8xCzAJBgNVBAYTAlNF" +
+ "MRIwEAYDVQQKDAlZdWJpY28gQUIxIjAgBgNVBAsMGUF1dGhlbnRpY2F0b3IgQXR0" +
+ "ZXN0YXRpb24xKDAmBgNVBAMMH1l1YmljbyBVMkYgRUUgU2VyaWFsIDE5NTUwMDM4" +
+ "NDIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASVXfOt9yR9MXXv/ZzE8xpOh466" +
+ "4YEJVmFQ+ziLLl9lJ79XQJqlgaUNCsUvGERcChNUihNTyKTlmnBOUjvATevto2ww" +
+ "ajAiBgkrBgEEAYLECgIEFTEuMy42LjEuNC4xLjQxNDgyLjEuMTATBgsrBgEEAYLl" +
+ "HAIBAQQEAwIFIDAhBgsrBgEEAYLlHAEBBAQSBBD4oBHzjApNFYAGFxEfntx9MAwG" +
+ "A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQELBQADggEBADFcSIDmmlJ+OGaJvWn9Cqhv" +
+ "SeueToVFQVVvqtALOgCKHdwB+Wx29mg2GpHiMsgQp5xjB0ybbnpG6x212FxESJ+G" +
+ "inZD0ipchi7APwPlhIvjgH16zVX44a4e4hOsc6tLIOP71SaMsHuHgCcdH0vg5d2s" +
+ "c006WJe9TXO6fzV+ogjJnYpNKQLmCXoAXE3JBNwKGBIOCvfQDPyWmiiG5bGxYfPt" +
+ "y8Z3pnjX+1MDnM2hhr40ulMxlSNDnX/ZSnDyMGIbk8TOQmjTF02UO8auP8k3wt5D" +
+ "1rROIRU9+FCSX5WQYi68RuDrGMZB8P5+byoJqbKQdxn2LmE1oZAyohPAmLcoPO4=";
+ if (window.internals) {
+ internals.setMockWebAuthenticationConfiguration({ silentFailure: true, hid: { payloadBase64: [testCreationMessageBase64] } });
+ internals.withUserGesture(() => { input.focus(); });
+ }
+
+ const options = {
+ publicKey: {
+ rp: {
+ name: "localhost",
+ },
+ user: {
+ name: "John Appleseed",
+ id: new Uint8Array(16),
+ displayName: "Appleseed",
+ },
+ challenge: new Uint8Array(16),
+ pubKeyCredParams: [{ type: "public-key", alg: -7 }],
+ timeout: 100
+ }
+ };
+
+ navigator.credentials.create(options);
+</script>