Title: [245215] trunk
Revision
245215
Author
[email protected]
Date
2019-05-12 16:05:20 -0700 (Sun, 12 May 2019)

Log Message

[Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
https://bugs.webkit.org/show_bug.cgi?id=197650

Patch by Takashi Komori <[email protected]> on 2019-05-12
Reviewed by Fujii Hironori.

Source/WebCore:

When Curl port accesses a page which checks Basic Authentication credential and server trust challenge occurs,
Curl port calls extra didReceiveAuthenticationChallenge unnecessarily.
This is because Curl port discards information about allowed server trust challenge before in NetworkDataTaskCurl::restartWithCredential.

Test: http/tests/ssl/curl/certificate-and-authentication.html

* platform/network/curl/CurlRequest.h:
(WebCore::CurlRequest::isServerTrustEvaluationDisabled):

Source/WebKit:

* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
(WebKit::NetworkDataTaskCurl::restartWithCredential):

LayoutTests:

* TestExpectations:
* http/tests/resources/basic-auth.php: Added.
* http/tests/ssl/curl/certificate-and-authentication-expected.txt: Added.
* http/tests/ssl/curl/certificate-and-authentication.html: Added.
* platform/wincairo-wk1/TestExpectations:
* platform/wincairo/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245214 => 245215)


--- trunk/LayoutTests/ChangeLog	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/LayoutTests/ChangeLog	2019-05-12 23:05:20 UTC (rev 245215)
@@ -1,3 +1,17 @@
+2019-05-12  Takashi Komori  <[email protected]>
+
+        [Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
+        https://bugs.webkit.org/show_bug.cgi?id=197650
+
+        Reviewed by Fujii Hironori.
+
+        * TestExpectations:
+        * http/tests/resources/basic-auth.php: Added.
+        * http/tests/ssl/curl/certificate-and-authentication-expected.txt: Added.
+        * http/tests/ssl/curl/certificate-and-authentication.html: Added.
+        * platform/wincairo-wk1/TestExpectations:
+        * platform/wincairo/TestExpectations:
+
 2019-05-11  Simon Fraser  <[email protected]>
 
         Overflow scroll that becomes non-scrollable should stop being composited

Modified: trunk/LayoutTests/TestExpectations (245214 => 245215)


--- trunk/LayoutTests/TestExpectations	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/LayoutTests/TestExpectations	2019-05-12 23:05:20 UTC (rev 245215)
@@ -52,6 +52,7 @@
 http/tests/preload/viewport [ Skip ]
 http/tests/gzip-content-encoding [ Skip ]
 http/tests/cookies/same-site [ Skip ]
+http/tests/ssl/curl [ Skip ]
 system-preview [ Skip ]
 editing/images [ Skip ]
 pointerevents/ios [ Skip ]

Added: trunk/LayoutTests/http/tests/resources/basic-auth.php (0 => 245215)


--- trunk/LayoutTests/http/tests/resources/basic-auth.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/resources/basic-auth.php	2019-05-12 23:05:20 UTC (rev 245215)
@@ -0,0 +1,10 @@
+<?php
+  if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_REQUEST['uid']) || ($_REQUEST['uid'] != $_SERVER['PHP_AUTH_USER'])) {
+   header('WWW-Authenticate: Basic realm="WebKit Test Realm"');
+   header('HTTP/1.0 401 Unauthorized');
+   echo 'Authentication canceled';
+   exit;
+  } else {
+   echo "User: {$_SERVER['PHP_AUTH_USER']}, password: {$_SERVER['PHP_AUTH_PW']}.";
+  }
+?>

Added: trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication-expected.txt (0 => 245215)


--- trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication-expected.txt	2019-05-12 23:05:20 UTC (rev 245215)
@@ -0,0 +1,4 @@
+localhost:8443 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with user:
+
+PASS Certificate validation and basic authentication 
+

Added: trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication.html (0 => 245215)


--- trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/curl/certificate-and-authentication.html	2019-05-12 23:05:20 UTC (rev 245215)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<!-- This is a test for https://bugs.webkit.org/show_bug.cgi?id=197650 -->
+<title>Certificate validation and basic authentication</title>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+function with_iframe(url) {
+    return new Promise(function(resolve) {
+        var frame = document.createElement('iframe');
+        frame.className = 'test-iframe';
+        frame.src = ""
+        frame._onload_ = function() { resolve(frame); };
+        document.body.appendChild(frame);
+    });
+}
+
+async function doTest()
+{
+    assert_true(!!window.testRunner, "Test requires testRunner");
+
+    window.testRunner.setAllowsAnySSLCertificate(true);
+    window.testRunner.setHandlesAuthenticationChallenges(true);
+    window.testRunner.setAuthenticationUsername("user");
+    window.testRunner.setAuthenticationPassword("");
+
+    const currentCallbackCounts = window.testRunner.serverTrustEvaluationCallbackCallsCount;
+
+    const iframe = await with_iframe("https://localhost:8443/resources/basic-auth.php?uid=user");
+    iframe.remove();
+
+    assert_equals(window.testRunner.serverTrustEvaluationCallbackCallsCount - currentCallbackCounts, 1);
+}
+
+doTest().then(done, (e) => { assert_unreached("test failed: " + e); done(); });
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (245214 => 245215)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2019-05-12 23:05:20 UTC (rev 245215)
@@ -948,6 +948,7 @@
 http/tests/security/cookies/third-party-cookie-blocking-user-action.html [ Pass ]
 http/tests/security/cookies/third-party-cookie-blocking-xslt.xml [ Pass ]
 
+http/tests/ssl/curl/certificate-and-authentication.html [ Pass ]
 http/tests/ssl/media-stream [ Skip ]
 
 [ Debug ] http/tests/storage/callbacks-are-called-in-correct-context.html [ Skip ]

Modified: trunk/LayoutTests/platform/wincairo-wk1/TestExpectations (245214 => 245215)


--- trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2019-05-12 23:05:20 UTC (rev 245215)
@@ -21,6 +21,7 @@
 http/tests/security/cookies/third-party-cookie-blocking-xslt.xml [ Skip ]
 
 # Server trust evaluation only supported in WK2.
+http/tests/ssl/curl/certificate-and-authentication.html [ Skip ]
 http/tests/ssl/iframe-upgrade.https.html [ Skip ]
 http/tests/ssl/mixedContent/insecure-websocket.html [ Failure ]
 http/tests/ssl/upgrade-origin-usage.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (245214 => 245215)


--- trunk/Source/WebCore/ChangeLog	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/Source/WebCore/ChangeLog	2019-05-12 23:05:20 UTC (rev 245215)
@@ -1,3 +1,19 @@
+2019-05-12  Takashi Komori  <[email protected]>
+
+        [Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
+        https://bugs.webkit.org/show_bug.cgi?id=197650
+
+        Reviewed by Fujii Hironori.
+
+        When Curl port accesses a page which checks Basic Authentication credential and server trust challenge occurs,
+        Curl port calls extra didReceiveAuthenticationChallenge unnecessarily.
+        This is because Curl port discards information about allowed server trust challenge before in NetworkDataTaskCurl::restartWithCredential.
+
+        Test: http/tests/ssl/curl/certificate-and-authentication.html
+
+        * platform/network/curl/CurlRequest.h:
+        (WebCore::CurlRequest::isServerTrustEvaluationDisabled):
+
 2019-05-11  Simon Fraser  <[email protected]>
 
         Overflow scroll that becomes non-scrollable should stop being composited

Modified: trunk/Source/WebCore/platform/network/curl/CurlRequest.h (245214 => 245215)


--- trunk/Source/WebCore/platform/network/curl/CurlRequest.h	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/Source/WebCore/platform/network/curl/CurlRequest.h	2019-05-12 23:05:20 UTC (rev 245215)
@@ -74,6 +74,7 @@
     void invalidateClient();
     WEBCORE_EXPORT void setAuthenticationScheme(ProtectionSpaceAuthenticationScheme);
     WEBCORE_EXPORT void setUserPass(const String&, const String&);
+    bool isServerTrustEvaluationDisabled() { return m_shouldDisableServerTrustEvaluation; }
     void disableServerTrustEvaluation() { m_shouldDisableServerTrustEvaluation = true; }
     void setStartTime(const MonotonicTime& startTime) { m_requestStartTime = startTime; }
 

Modified: trunk/Source/WebKit/ChangeLog (245214 => 245215)


--- trunk/Source/WebKit/ChangeLog	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/Source/WebKit/ChangeLog	2019-05-12 23:05:20 UTC (rev 245215)
@@ -1,3 +1,13 @@
+2019-05-12  Takashi Komori  <[email protected]>
+
+        [Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
+        https://bugs.webkit.org/show_bug.cgi?id=197650
+
+        Reviewed by Fujii Hironori.
+
+        * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
+        (WebKit::NetworkDataTaskCurl::restartWithCredential):
+
 2019-05-10  Chris Dumez  <[email protected]>
 
         [PSON] Prevent flashing when the process-swap is forced by the client

Modified: trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp (245214 => 245215)


--- trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp	2019-05-12 22:50:21 UTC (rev 245214)
+++ trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp	2019-05-12 23:05:20 UTC (rev 245215)
@@ -425,12 +425,13 @@
     ASSERT(m_curlRequest);
 
     auto previousRequest = m_curlRequest->resourceRequest();
+    auto shouldDisableServerTrustEvaluation = protectionSpace.authenticationScheme() == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested || m_curlRequest->isServerTrustEvaluationDisabled();
     m_curlRequest->cancel();
 
     m_curlRequest = createCurlRequest(WTFMove(previousRequest), RequestStatus::ReusedRequest);
     m_curlRequest->setAuthenticationScheme(protectionSpace.authenticationScheme());
     m_curlRequest->setUserPass(credential.user(), credential.password());
-    if (protectionSpace.authenticationScheme() == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested)
+    if (shouldDisableServerTrustEvaluation)
         m_curlRequest->disableServerTrustEvaluation();
     m_curlRequest->setStartTime(m_startTime);
     m_curlRequest->start();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to