From 544595f3e1696eb92e4831688e0fa9fe596a4c52 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 6 Jan 2020 14:02:28 -0800 Subject: [PATCH] browser(webkit): treat empty credentials as enabled auth interception (#385) --- browser_patches/webkit/BUILD_NUMBER | 2 +- browser_patches/webkit/patches/bootstrap.diff | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 36804484be..69ed05c04b 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1 +1 @@ -1062 +1063 diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff index f33c007013..b17e54e1ea 100644 --- a/browser_patches/webkit/patches/bootstrap.diff +++ b/browser_patches/webkit/patches/bootstrap.diff @@ -6936,7 +6936,7 @@ index 78caedf0c0ce83675569502d150fcc44e5f9868c..ae6b43a49986380a521dcfbe8d5dc9e3 } // namespace WebKit diff --git a/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp new file mode 100644 -index 0000000000000000000000000000000000000000..58e69943a8978790fbe6fa0f478c64dd2895a551 +index 0000000000000000000000000000000000000000..ca238991a6fed35f2b18d46735fbac7243794a5f --- /dev/null +++ b/Source/WebKit/UIProcess/WebPageInspectorEmulationAgent.cpp @@ -0,0 +1,63 @@ @@ -6999,7 +6999,7 @@ index 0000000000000000000000000000000000000000..58e69943a8978790fbe6fa0f478c64dd + if (username && password) + m_page.setAuthCredentialsForAutomation(WebCore::Credential(*username, *password, CredentialPersistencePermanent)); + else -+ m_page.setAuthCredentialsForAutomation(WebCore::Credential()); ++ m_page.setAuthCredentialsForAutomation(Optional()); +} + +} // namespace WebKit @@ -7536,7 +7536,7 @@ index 0000000000000000000000000000000000000000..033f936d9d3caf594b78bb6ad39249d6 + +} // namespace WebKit diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp -index 9b868717128b9f0b592c94c3b325507d99d6797b..3790500d0c6018c994d5fd5ba4e2eec77be5817a 100644 +index 9b868717128b9f0b592c94c3b325507d99d6797b..876cd00e9e9c5d95d7d3069012653d4c4584deea 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit/UIProcess/WebPageProxy.cpp @@ -889,6 +889,7 @@ void WebPageProxy::finishAttachingToWebProcess(ProcessLaunchReason reason) @@ -7556,7 +7556,7 @@ index 9b868717128b9f0b592c94c3b325507d99d6797b..3790500d0c6018c994d5fd5ba4e2eec7 + m_inputProcessingObserver = observer; +} + -+void WebPageProxy::setAuthCredentialsForAutomation(WebCore::Credential&& credentials) { ++void WebPageProxy::setAuthCredentialsForAutomation(Optional&& credentials) { + m_credentialsForAutomation = WTFMove(credentials); +} + @@ -7667,18 +7667,22 @@ index 9b868717128b9f0b592c94c3b325507d99d6797b..3790500d0c6018c994d5fd5ba4e2eec7 if (m_loaderClient) handledByClient = reason != ProcessTerminationReason::RequestedByClient && m_loaderClient->processDidCrash(*this); else -@@ -7595,6 +7621,10 @@ void WebPageProxy::gamepadActivity(const Vector& gamepadDatas, bool +@@ -7595,6 +7621,14 @@ void WebPageProxy::gamepadActivity(const Vector& gamepadDatas, bool void WebPageProxy::didReceiveAuthenticationChallengeProxy(Ref&& authenticationChallenge) { -+ if (!m_credentialsForAutomation.isEmpty() && !authenticationChallenge->core().previousFailureCount()) { -+ authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::UseCredential, m_credentialsForAutomation); ++ if (m_credentialsForAutomation.hasValue()) { ++ if (m_credentialsForAutomation->isEmpty() || authenticationChallenge->core().previousFailureCount()) { ++ authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling); ++ return; ++ } ++ authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::UseCredential, *m_credentialsForAutomation); + return; + } m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get()); } -@@ -7656,7 +7686,8 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, +@@ -7656,7 +7690,8 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, MESSAGE_CHECK(m_process, frame); // FIXME: Geolocation should probably be using toString() as its string representation instead of databaseIdentifier(). @@ -7688,7 +7692,7 @@ index 9b868717128b9f0b592c94c3b325507d99d6797b..3790500d0c6018c994d5fd5ba4e2eec7 auto request = m_geolocationPermissionRequestManager.createRequest(geolocationID); Function completionHandler = [request = WTFMove(request)](bool allowed) { if (allowed) -@@ -7664,6 +7695,11 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, +@@ -7664,6 +7699,11 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, else request->deny(); }; @@ -7701,7 +7705,7 @@ index 9b868717128b9f0b592c94c3b325507d99d6797b..3790500d0c6018c994d5fd5ba4e2eec7 // FIXME: Once iOS migrates to the new WKUIDelegate SPI, clean this up // and make it one UIClient call that calls the completionHandler with false diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h -index 8189e085e43ea304b38ff84e41e6e49f10c8da20..dc1eeb8cd5c35c1ee5020cbe72639de559d7f952 100644 +index 8189e085e43ea304b38ff84e41e6e49f10c8da20..c07e4bca568d77d842695c206eb21108b3b98d71 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.h +++ b/Source/WebKit/UIProcess/WebPageProxy.h @@ -35,6 +35,7 @@ @@ -7732,7 +7736,7 @@ index 8189e085e43ea304b38ff84e41e6e49f10c8da20..dc1eeb8cd5c35c1ee5020cbe72639de5 + virtual void didProcessAllPendingMouseEvents() = 0; + }; + void setObserber(InputProcessingObserver*); -+ void setAuthCredentialsForAutomation(WebCore::Credential&&); ++ void setAuthCredentialsForAutomation(Optional&&); + void setPermissionsForAutomation(const HashMap>&); + void initializeWebPage(); @@ -7758,7 +7762,7 @@ index 8189e085e43ea304b38ff84e41e6e49f10c8da20..dc1eeb8cd5c35c1ee5020cbe72639de5 bool m_isLayerTreeFrozenDueToSwipeAnimation { false }; String m_overriddenMediaType; -+ WebCore::Credential m_credentialsForAutomation; ++ Optional m_credentialsForAutomation; + HashMap> m_permissionsForAutomation; #if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)