WebKit Bugzilla
Attachment 372962 Details for
Bug 199232
: SubFrameSOAuthorizationSession should preserve the referrer header when falling back to web path
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199232-20190626161450.patch (text/plain), 12.36 KB, created by
Jiewen Tan
on 2019-06-26 16:14:51 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jiewen Tan
Created:
2019-06-26 16:14:51 PDT
Size:
12.36 KB
patch
obsolete
>Subversion Revision: 246840 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0b692e71fc4dd6bb1949f7b33aa2da7a177a29c3..f6eba8091b04aa146739dd954a41d19f226f01a0 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2019-06-26 Jiewen Tan <jiewen_tan@apple.com> >+ >+ SubFrameSOAuthorizationSession should preserve the referrer header when fall back to web path >+ https://bugs.webkit.org/show_bug.cgi?id=199232 >+ <rdar://problem/51718328> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The fall back to web path mechanism in SubFrameSOAuthorizationSession doesn't actually resume >+ the previous navigation. Instead it starts a new one. The current implementation doesn't carry >+ any information from the previous navigation. It is problematic when it comes to http referrer >+ as the server might use that to determine what kind of responses to send back. Therefore, we >+ add that information now. >+ >+ To accomplish the above, the patch teaches WebFrameProxy::loadURL to carry referrer information >+ when it is available. Then SubFrameSOAuthorizationSession can reuses the referrer from the >+ original request. >+ >+ * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm: >+ (WebKit::SubFrameSOAuthorizationSession::fallBackToWebPathInternal): >+ * UIProcess/WebFrameProxy.cpp: >+ (WebKit::WebFrameProxy::loadURL): >+ * UIProcess/WebFrameProxy.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::loadURLInFrame): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ > 2019-06-26 Zalan Bujtas <zalan@apple.com> > > [ContentChangeObserver] Dispatch synthetic mouse event asynchronously in completePendingSyntheticClickForContentChangeObserver >diff --git a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm >index 065661430fec1c27c0bc3db8bd0d07b9eae9f24d..aa14bc341a0f1c09538c16125ffc292562e0d120 100644 >--- a/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm >+++ b/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm >@@ -68,7 +68,7 @@ void SubFrameSOAuthorizationSession::fallBackToWebPathInternal() > if (auto* frame = page->process().webFrame(targetFrame->handle().frameID())) { > page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision(); > // Issue a new load to the original URL as the original load is aborted before start. >- frame->loadURL(navigationActionPtr->request().url()); >+ frame->loadURL(navigationActionPtr->request().url(), navigationActionPtr->request().httpReferrer()); > } > } > }); >diff --git a/Source/WebKit/UIProcess/WebFrameProxy.cpp b/Source/WebKit/UIProcess/WebFrameProxy.cpp >index b43926c9c4206c93d88c16842a424dbce66691fc..0714b41eb67768d9e0c9d412e20e898f81e73dd8 100644 >--- a/Source/WebKit/UIProcess/WebFrameProxy.cpp >+++ b/Source/WebKit/UIProcess/WebFrameProxy.cpp >@@ -79,12 +79,12 @@ bool WebFrameProxy::isMainFrame() const > return this == m_page->mainFrame() || (m_page->provisionalPageProxy() && this == m_page->provisionalPageProxy()->mainFrame()); > } > >-void WebFrameProxy::loadURL(const URL& url) >+void WebFrameProxy::loadURL(const URL& url, const String& referrer) > { > if (!m_page) > return; > >- m_page->process().send(Messages::WebPage::LoadURLInFrame(url, m_frameID), m_page->pageID()); >+ m_page->process().send(Messages::WebPage::LoadURLInFrame(url, referrer, m_frameID), m_page->pageID()); > } > > void WebFrameProxy::loadData(const IPC::DataReference& data, const String& MIMEType, const String& encodingName, const URL& baseURL) >diff --git a/Source/WebKit/UIProcess/WebFrameProxy.h b/Source/WebKit/UIProcess/WebFrameProxy.h >index 6809e544c7cc6fedc87244de0714b6b36191daab..44600f1c27290e5e4c168ea8cd3cc39636fdbbe1 100644 >--- a/Source/WebKit/UIProcess/WebFrameProxy.h >+++ b/Source/WebKit/UIProcess/WebFrameProxy.h >@@ -78,7 +78,7 @@ public: > > FrameLoadState& frameLoadState() { return m_frameLoadState; } > >- void loadURL(const URL&); >+ void loadURL(const URL&, const String& referrer = String()); > // Sub frames only. For main frames, use WebPageProxy::loadData. > void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const URL& baseURL); > void stopLoading() const; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 7f0de8c82b0d2ea84c32209aa455b0ec4770ef27..3962e282f552940a483a4bbbb0746b49fb7a1a4d 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -1488,13 +1488,13 @@ void WebPage::suspendForProcessSwap() > send(Messages::WebPageProxy::DidSuspendAfterProcessSwap()); > } > >-void WebPage::loadURLInFrame(URL&& url, uint64_t frameID) >+void WebPage::loadURLInFrame(URL&& url, const String& referrer, uint64_t frameID) > { > WebFrame* frame = WebProcess::singleton().webFrame(frameID); > if (!frame) > return; > >- frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(url), ShouldOpenExternalURLsPolicy::ShouldNotAllow)); >+ frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(url, referrer), ShouldOpenExternalURLsPolicy::ShouldNotAllow)); > } > > void WebPage::loadDataInFrame(IPC::DataReference&& data, String&& MIMEType, String&& encodingName, URL&& baseURL, uint64_t frameID) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index d5423bbb3c5fdf832a658c28690b4a6399c9f315..39d0c219616fcb27c207faeb84120b952c6dbc21 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1337,7 +1337,7 @@ private: > static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity); > static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity); > >- void loadURLInFrame(URL&&, uint64_t frameID); >+ void loadURLInFrame(URL&&, const String& referrer, uint64_t frameID); > void loadDataInFrame(IPC::DataReference&&, String&& MIMEType, String&& encodingName, URL&& baseURL, uint64_t frameID); > > enum class WasRestoredByAPIRequest { No, Yes }; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index d9822d3880b88a5e5584698fe96accb737b80454..6346cd032e2b1928b4dba37550d982755755aad4 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -158,7 +158,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType > GoToBackForwardItem(uint64_t navigationID, struct WebCore::BackForwardItemIdentifier backForwardItemID, enum:uint8_t WebCore::FrameLoadType backForwardType, enum:bool WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, Optional<WebKit::WebsitePoliciesData> websitePolicies) > TryRestoreScrollPosition() > >- LoadURLInFrame(URL url, uint64_t frameID) >+ LoadURLInFrame(URL url, String referrer, uint64_t frameID) > LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, uint64_t frameID) > LoadRequest(struct WebKit::LoadParameters loadParameters) > LoadData(struct WebKit::LoadParameters loadParameters) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 09ee37039a62009873e10641fd6bc5667fb26374..00e92bd76d3ab85d9e711ac699d40bee82f628f7 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2019-06-26 Jiewen Tan <jiewen_tan@apple.com> >+ >+ SubFrameSOAuthorizationSession should preserve the referrer header when fall back to web path >+ https://bugs.webkit.org/show_bug.cgi?id=199232 >+ <rdar://problem/51718328> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm: >+ (TestWebKitAPI::TEST): >+ Add a test that utilizes TCPServer as local files always omit referrer. >+ > 2019-06-25 Jiewen Tan <jiewen_tan@apple.com> > > Implement a new SPI to inform clients about AppSSO >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm >index e73d20b3b4e5a3cc1f30c3390656e9f856e4a3e4..ab15331f77cf726988b6c829ca589c18703bcb8e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm >@@ -31,16 +31,19 @@ > #import "ClassMethodSwizzler.h" > #import "InstanceMethodSwizzler.h" > #import "PlatformUtilities.h" >+#import "TCPServer.h" > #import "TestWKWebView.h" > #import <WebKit/WKNavigationActionPrivate.h> > #import <WebKit/WKNavigationDelegatePrivate.h> > #import <WebKit/WKNavigationPrivate.h> >+#import <WebKit/WKWebViewPrivate.h> > #import <pal/cocoa/AppSSOSoftLink.h> > #import <pal/spi/cocoa/AuthKitSPI.h> > #import <wtf/BlockPtr.h> > #import <wtf/RetainPtr.h> > #import <wtf/StringPrintStream.h> > #import <wtf/URL.h> >+#import <wtf/text/StringConcatenateNumbers.h> > #import <wtf/text/WTFString.h> > > static bool navigationCompleted = false; >@@ -95,6 +98,7 @@ static const char* newWindowResponseTemplate = > > static const char* parentTemplate = > "<html>" >+"<meta name='referrer' content='origin' />" > "<iframe src='%s'></iframe>" > "<script>" > "function receiveMessage(event)" >@@ -110,6 +114,7 @@ static const char* iframeTemplate = > "<html>" > "<script>" > "parent.postMessage('Hello.', '*');" >+"%s" > "</script>" > "</html>"; > >@@ -2124,6 +2129,51 @@ TEST(SOAuthorizationSubFrame, SOAuthorizationLoadPolicyIgnoreAsync) > EXPECT_FALSE(authorizationPerformed); > } > >+TEST(SOAuthorizationSubFrame, InterceptionErrorWithReferrer) >+{ >+ resetState(); >+ ClassMethodSwizzler swizzler1(PAL::getSOAuthorizationClass(), @selector(canPerformAuthorizationWithURL:responseCode:), reinterpret_cast<IMP>(overrideCanPerformAuthorizationWithURL)); >+ InstanceMethodSwizzler swizzler2(PAL::getSOAuthorizationClass(), @selector(setDelegate:), reinterpret_cast<IMP>(overrideSetDelegate)); >+ InstanceMethodSwizzler swizzler3(PAL::getSOAuthorizationClass(), @selector(beginAuthorizationWithURL:httpHeaders:httpBody:), reinterpret_cast<IMP>(overrideBeginAuthorizationWithURL)); >+ ClassMethodSwizzler swizzler4([AKAuthorizationController class], @selector(isURLFromAppleOwnedDomain:), reinterpret_cast<IMP>(overrideIsURLFromAppleOwnedDomain)); >+ >+ TCPServer server([parentHtml = generateHtml(parentTemplate, "simple.html"), frameHtml = generateHtml(iframeTemplate, "parent.postMessage('Referrer: ' + document.referrer, '*');")] (int socket) { >+ NSString *firstResponse = [NSString stringWithFormat: >+ @"HTTP/1.1 200 OK\r\n" >+ "Content-Length: %d\r\n\r\n" >+ "%@", >+ parentHtml.length(), >+ (id)parentHtml >+ ]; >+ NSString *secondResponse = [NSString stringWithFormat: >+ @"HTTP/1.1 200 OK\r\n" >+ "Content-Length: %d\r\n\r\n" >+ "%@", >+ frameHtml.length(), >+ (id)frameHtml >+ ]; >+ >+ TCPServer::read(socket); >+ TCPServer::write(socket, firstResponse.UTF8String, firstResponse.length); >+ TCPServer::read(socket); >+ TCPServer::write(socket, secondResponse.UTF8String, secondResponse.length); >+ }); >+ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); >+ configureSOAuthorizationWebView(webView.get(), delegate.get()); >+ >+ auto origin = makeString("http://127.0.0.1:", static_cast<unsigned>(server.port())); >+ [webView _loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)origin]] shouldOpenExternalURLs:NO]; >+ [webView waitForMessage:(id)origin]; >+ [webView waitForMessage:@"SOAuthorizationDidStart"]; >+ >+ [gDelegate authorization:gAuthorization didCompleteWithError:adoptNS([[NSError alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil]).get()]; >+ [webView waitForMessage:(id)origin]; >+ [webView waitForMessage:@"SOAuthorizationDidCancel"]; >+ [webView waitForMessage:(id)makeString("Referrer: ", origin, "/")]; // Referrer policy requires '/' after origin. >+} >+ > } // namespace TestWebKitAPI > > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199232
:
372947
| 372962