Changeset 283565 in webkit
- Timestamp:
- Oct 5, 2021, 11:48:10 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/fetch/fetch-redirect-same-origin-authorization-expected.txt (added)
-
LayoutTests/http/tests/fetch/fetch-redirect-same-origin-authorization.html (added)
-
LayoutTests/http/tests/fetch/resources/dump-authorization-header.py (added)
-
LayoutTests/http/tests/xmlhttprequest/redirections-and-user-headers.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (modified) (1 diff)
-
Source/WebCore/platform/network/mac/ResourceHandleMac.mm (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r283562 r283565 1 2021-10-05 Chris Dumez <cdumez@apple.com> 2 3 Authorization header lost on 30x redirects 4 https://bugs.webkit.org/show_bug.cgi?id=230935 5 <rdar://problem/83689955> 6 7 Reviewed by Darin Adler. 8 9 * http/tests/fetch/fetch-redirect-same-origin-authorization-expected.txt: Added. 10 * http/tests/fetch/fetch-redirect-same-origin-authorization.html: Added. 11 * http/tests/fetch/resources/dump-authorization-header.py: Added. 12 Add layout test coverage. 13 14 * http/tests/xmlhttprequest/redirections-and-user-headers.html: 15 Update existing test to reflect behavior change. 16 1 17 2021-10-05 Gabriel Nava Marino <gnavamarino@apple.com> 2 18 -
trunk/LayoutTests/http/tests/xmlhttprequest/redirections-and-user-headers.html
r272548 r283565 8 8 <body> 9 9 <script type="text/javascript"> 10 function doTest(testName, testURL, simpleRequest, c hangeOrigin)10 function doTest(testName, testURL, simpleRequest, crossOriginRedirect) 11 11 { 12 12 promise_test(function(test) { … … 32 32 assert_true(xhr.responseText.indexOf("x-webkit header found: funky") !== -1, "xhr final request should have a x-webkit=funky header"); 33 33 assert_true(xhr.responseText.indexOf("content-type header found: rocky") !== -1, "xhr final request should have a content-type=groovy header"); 34 assert_true(xhr.responseText.indexOf("not found any authorization header") !== -1, "xhr final request should not have an authorization header"); 34 if (crossOriginRedirect) 35 assert_true(xhr.responseText.indexOf("not found any authorization header") !== -1, "xhr final request should not have an authorization header"); 36 else 37 assert_true(xhr.responseText.indexOf("authorization header found") !== -1, "xhr final request should have an authorization header"); 35 38 } 36 39 testPassed = true; … … 51 54 52 55 var simpleRequest = true; 56 var crossOriginRedirect = true; 53 57 54 58 doTest("Check headers after same-origin redirection to same-origin resource (simple request)", 55 59 "resources/access-control-preflight-redirect.py?redirect=true&url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-preflight-redirect.py", 56 simpleRequest );60 simpleRequest, !crossOriginRedirect); 57 61 58 62 doTest("Check headers after same-origin redirection to same-origin resource (not simple request)", 59 63 "resources/access-control-preflight-redirect.py?redirect=true&url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-preflight-redirect.py", 60 !simpleRequest );64 !simpleRequest, !crossOriginRedirect); 61 65 62 66 doTest("Check headers after same origin redirection to cross-origin resource (simple request)", 63 67 "resources/access-control-preflight-redirect.py?redirect=true&url=http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py", 64 simpleRequest );68 simpleRequest, crossOriginRedirect); 65 69 66 70 doTest("Check headers after same origin redirection to cross-origin resource (not simple request)", 67 71 "resources/access-control-preflight-redirect.py?redirect=true&url=http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py", 68 !simpleRequest );72 !simpleRequest, crossOriginRedirect); 69 73 70 74 doTest("Check headers after cross-origin redirection to same-origin resource (simple request)", 71 75 "http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py?redirect=true&url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-preflight-redirect.py", 72 simpleRequest );76 simpleRequest, crossOriginRedirect); 73 77 74 78 doTest("Check headers after cross-origin redirection to same-origin resource (not simple request)", 75 79 "http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py?redirect=true&url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-preflight-redirect.py", 76 !simpleRequest );80 !simpleRequest, crossOriginRedirect); 77 81 78 82 doTest("Check headers after cross-origin redirection to cross-origin resource (simple request)", 79 83 "http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py?redirect=true&url=http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py", 80 simpleRequest );84 simpleRequest, !crossOriginRedirect); 81 85 82 86 doTest("Check headers after cross-origin redirection to cross-origin resource (not simple request)", 83 87 "http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py?redirect=true&url=http://localhost:8080/xmlhttprequest/resources/access-control-preflight-redirect.py", 84 !simpleRequest );88 !simpleRequest, !crossOriginRedirect); 85 89 86 90 </script> -
trunk/Source/WebCore/ChangeLog
r283564 r283565 1 2021-10-05 Chris Dumez <cdumez@apple.com> 2 3 Authorization header lost on 30x redirects 4 https://bugs.webkit.org/show_bug.cgi?id=230935 5 <rdar://problem/83689955> 6 7 Reviewed by Darin Adler. 8 9 CFNetwork drops the Authorization request header in cases of same-origin redirects, which is not as per 10 the fetch specification [1] and doesn't match the behavior of other browsers. 11 12 To address the issue, WebKit adds the Authorization request back in case of a same-origin redirect. 13 14 Test: http/tests/fetch/fetch-redirect-same-origin-authorization.html 15 16 * platform/network/cf/ResourceHandleCFNet.cpp: 17 (WebCore::ResourceHandle::willSendRequest): 18 * platform/network/mac/ResourceHandleMac.mm: 19 (WebCore::ResourceHandle::willSendRequest): 20 1 21 2021-10-05 Andres Gonzalez <andresg_22@apple.com> 2 22 -
trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
r282853 r283565 289 289 request.clearHTTPOrigin(); 290 290 } else { 291 if (auto authorization = d->m_firstRequest.httpHeaderField(HTTPHeaderName::Authorization); !authorization.isNull()) 292 request.setHTTPHeaderField(HTTPHeaderName::Authorization, authorization); 293 291 294 // Only consider applying authentication credentials if this is actually a redirect and the redirect 292 295 // URL didn't include credentials of its own. -
trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm
r282853 r283565 445 445 request.clearHTTPOrigin(); 446 446 } else { 447 if (auto authorization = d->m_firstRequest.httpHeaderField(HTTPHeaderName::Authorization); !authorization.isNull()) 448 request.setHTTPHeaderField(HTTPHeaderName::Authorization, authorization); 449 447 450 // Only consider applying authentication credentials if this is actually a redirect and the redirect 448 451 // URL didn't include credentials of its own. -
trunk/Source/WebKit/ChangeLog
r283563 r283565 1 2021-10-05 Chris Dumez <cdumez@apple.com> 2 3 Authorization header lost on 30x redirects 4 https://bugs.webkit.org/show_bug.cgi?id=230935 5 <rdar://problem/83689955> 6 7 Reviewed by Darin Adler. 8 9 CFNetwork drops the Authorization request header in cases of same-origin redirects, which is not as per 10 the fetch specification [1] and doesn't match the behavior of other browsers. 11 12 To address the issue, WebKit adds the Authorization request back in case of a same-origin redirect. 13 14 [1] https://fetch.spec.whatwg.org/#concept-http-redirect-fetch 15 16 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 17 (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): 18 1 19 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 20 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r283509 r283565 507 507 request.clearHTTPAuthorization(); 508 508 request.clearHTTPOrigin(); 509 510 } else { 511 if (auto authorization = m_firstRequest.httpHeaderField(WebCore::HTTPHeaderName::Authorization); !authorization.isNull()) 512 request.setHTTPHeaderField(WebCore::HTTPHeaderName::Authorization, authorization); 513 509 514 #if USE(CREDENTIAL_STORAGE_WITH_NETWORK_SESSION) 510 } else {511 515 // Only consider applying authentication credentials if this is actually a redirect and the redirect 512 516 // URL didn't include credentials of its own. … … 519 523 applyBasicAuthorizationHeader(request, m_initialCredential); 520 524 } 525 #endif 521 526 } 522 #endif523 527 } 524 528
Note:
See TracChangeset
for help on using the changeset viewer.