Diff
Modified: trunk/Source/WebCore/ChangeLog (247269 => 247270)
--- trunk/Source/WebCore/ChangeLog 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebCore/ChangeLog 2019-07-09 19:25:57 UTC (rev 247270)
@@ -1,3 +1,29 @@
+2019-07-09 Sihui Liu <[email protected]>
+
+ Only allow fetching and removing session credentials from WebsiteDataStore
+ https://bugs.webkit.org/show_bug.cgi?id=199385
+ <rdar://problem/52622080>
+
+ Reviewed by Alex Christensen.
+
+ Fetch and remove only session credentials from NSURLCredentialStorage.
+
+ Modified existing API tests: WKWebsiteDataStore.FetchPersistentCredentials
+
+ * platform/network/CredentialStorage.cpp:
+ (WebCore::CredentialStorage::originsWithCredentials const):
+ (WebCore::CredentialStorage::originsWithSessionCredentials):
+ (WebCore::CredentialStorage::removeSessionCredentialsWithOrigins):
+ (WebCore::CredentialStorage::clearSessionCredentials):
+ (WebCore::CredentialStorage::clearPermanentCredentialsForProtectionSpace):
+ * platform/network/CredentialStorage.h:
+ * platform/network/mac/CredentialStorageMac.mm:
+ (WebCore::CredentialStorage::originsWithSessionCredentials):
+ (WebCore::CredentialStorage::removeSessionCredentialsWithOrigins):
+ (WebCore::CredentialStorage::clearSessionCredentials):
+ (WebCore::CredentialStorage::clearPermanentCredentialsForProtectionSpace):
+ (WebCore::CredentialStorage::originsWithPersistentCredentials): Deleted.
+
2019-07-09 Alex Christensen <[email protected]>
Null check HistoryItems given to loadDifferentDocumentItem
Modified: trunk/Source/WebCore/platform/network/CredentialStorage.cpp (247269 => 247270)
--- trunk/Source/WebCore/platform/network/CredentialStorage.cpp 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebCore/platform/network/CredentialStorage.cpp 2019-07-09 19:25:57 UTC (rev 247270)
@@ -102,9 +102,9 @@
remove(key.first, key.second);
}
-Vector<SecurityOriginData> CredentialStorage::originsWithCredentials() const
+HashSet<SecurityOriginData> CredentialStorage::originsWithCredentials() const
{
- Vector<SecurityOriginData> origins;
+ HashSet<SecurityOriginData> origins;
for (auto& keyValuePair : m_protectionSpaceToCredentialMap) {
auto& protectionSpace = keyValuePair.key.second;
if (protectionSpace.isProxy())
@@ -129,7 +129,7 @@
}
SecurityOriginData origin { protocol, protectionSpace.host(), static_cast<uint16_t>(protectionSpace.port())};
- origins.append(WTFMove(origin));
+ origins.add(WTFMove(origin));
}
return origins;
}
@@ -187,4 +187,23 @@
m_pathToDefaultProtectionSpaceMap.clear();
}
+#if !PLATFORM(COCOA)
+HashSet<SecurityOriginData> CredentialStorage::originsWithSessionCredentials()
+{
+ return { };
+}
+
+void CredentialStorage::removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>&)
+{
+}
+
+void CredentialStorage::clearSessionCredentials()
+{
+}
+
+void CredentialStorage::clearPermanentCredentialsForProtectionSpace(const ProtectionSpace&)
+{
+}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/CredentialStorage.h (247269 => 247270)
--- trunk/Source/WebCore/platform/network/CredentialStorage.h 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebCore/platform/network/CredentialStorage.h 2019-07-09 19:25:57 UTC (rev 247270)
@@ -45,9 +45,12 @@
WEBCORE_EXPORT void remove(const String&, const ProtectionSpace&);
WEBCORE_EXPORT void removeCredentialsWithOrigin(const SecurityOriginData&);
- // OS persistent storage.
+ // OS credential storage.
WEBCORE_EXPORT static Credential getFromPersistentStorage(const ProtectionSpace&);
- WEBCORE_EXPORT static Vector<SecurityOriginData> originsWithPersistentCredentials();
+ WEBCORE_EXPORT static HashSet<SecurityOriginData> originsWithSessionCredentials();
+ WEBCORE_EXPORT static void removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>& origins);
+ WEBCORE_EXPORT static void clearSessionCredentials();
+ WEBCORE_EXPORT static void clearPermanentCredentialsForProtectionSpace(const ProtectionSpace&);
WEBCORE_EXPORT void clearCredentials();
@@ -56,7 +59,7 @@
WEBCORE_EXPORT bool set(const String&, const Credential&, const URL&); // Returns true if the URL corresponds to a known protection space, so credentials could be updated.
WEBCORE_EXPORT Credential get(const String&, const URL&);
- WEBCORE_EXPORT Vector<SecurityOriginData> originsWithCredentials() const;
+ WEBCORE_EXPORT HashSet<SecurityOriginData> originsWithCredentials() const;
private:
HashMap<std::pair<String /* partitionName */, ProtectionSpace>, Credential> m_protectionSpaceToCredentialMap;
Modified: trunk/Source/WebCore/platform/network/mac/CredentialStorageMac.mm (247269 => 247270)
--- trunk/Source/WebCore/platform/network/mac/CredentialStorageMac.mm 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebCore/platform/network/mac/CredentialStorageMac.mm 2019-07-09 19:25:57 UTC (rev 247270)
@@ -38,13 +38,69 @@
return credential ? Credential(credential) : Credential();
}
-Vector<WebCore::SecurityOriginData> CredentialStorage::originsWithPersistentCredentials()
+HashSet<SecurityOriginData> CredentialStorage::originsWithSessionCredentials()
{
- Vector<WebCore::SecurityOriginData> origins;
+ HashSet<SecurityOriginData> origins;
auto allCredentials = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials];
- for (NSURLProtectionSpace* key in allCredentials.keyEnumerator)
- origins.append(WebCore::SecurityOriginData { String(key.protocol), String(key.host), key.port });
+ for (NSURLProtectionSpace* key in allCredentials.keyEnumerator) {
+ for (NSURLProtectionSpace* space in allCredentials) {
+ auto credentials = allCredentials[space];
+ for (NSString* user in credentials) {
+ if (credentials[user].persistence == NSURLCredentialPersistenceForSession) {
+ origins.add(WebCore::SecurityOriginData { String(key.protocol), String(key.host), key.port });
+ break;
+ }
+ }
+ }
+ }
return origins;
}
+void CredentialStorage::removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>& origins)
+{
+ auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];
+ auto allCredentials = [sharedStorage allCredentials];
+ for (auto& origin : origins) {
+ for (NSURLProtectionSpace* space in allCredentials) {
+ if (origin.protocol == String(space.protocol)
+ && origin.host == String(space.host)
+ && origin.port
+ && *origin.port == space.port) {
+ auto credentials = allCredentials[space];
+ for (NSString* user in credentials) {
+ auto credential = credentials[user];
+ if (credential.persistence == NSURLCredentialPersistenceForSession)
+ [sharedStorage removeCredential:credential forProtectionSpace:space];
+ }
+ }
+ }
+ }
+}
+
+void CredentialStorage::clearSessionCredentials()
+{
+ auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];
+ auto allCredentials = [sharedStorage allCredentials];
+ for (NSURLProtectionSpace* space in allCredentials.keyEnumerator) {
+ auto credentials = allCredentials[space];
+ for (NSString* user in credentials) {
+ auto credential = credentials[user];
+ if (credential.persistence == NSURLCredentialPersistenceForSession)
+ [sharedStorage removeCredential:credential forProtectionSpace:space];
+ }
+ }
+}
+
+void CredentialStorage::clearPermanentCredentialsForProtectionSpace(const ProtectionSpace& protectionSpace)
+{
+ auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];
+ auto allCredentials = [sharedStorage allCredentials];
+ auto credentials = allCredentials[protectionSpace.nsSpace()];
+ for (NSString* user in credentials) {
+ auto credential = credentials[user];
+ if (credential.persistence == NSURLCredentialPersistencePermanent)
+ [sharedStorage removeCredential:credentials[user] forProtectionSpace:protectionSpace.nsSpace()];
+ }
+}
+
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (247269 => 247270)
--- trunk/Source/WebKit/ChangeLog 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/ChangeLog 2019-07-09 19:25:57 UTC (rev 247270)
@@ -1,3 +1,39 @@
+2019-07-09 Sihui Liu <[email protected]>
+
+ Only allow fetching and removing session credentials from WebsiteDataStore
+ https://bugs.webkit.org/show_bug.cgi?id=199385
+ <rdar://problem/52622080>
+
+ Reviewed by Alex Christensen.
+
+ Stop sending an extra message to network process for fetching or removing persistent credentials.
+
+ Also introduce a new SPI for clearing persistent credentials created in test.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::clearPermanentCredentialsForProtectionSpace):
+ (WebKit::NetworkProcess::fetchWebsiteData):
+ (WebKit::NetworkProcess::deleteWebsiteData):
+ (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
+ (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains):
+ (WebKit::NetworkProcess::originsWithPersistentCredentials): Deleted.
+ (WebKit::NetworkProcess::removeCredentialsWithOrigins): Deleted.
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+ (WebKit::NetworkProcess::originsWithPersistentCredentials): Deleted.
+ (WebKit::NetworkProcess::removeCredentialsWithOrigins): Deleted.
+ * UIProcess/API/Cocoa/WKProcessPool.mm:
+ (-[WKProcessPool _clearPermanentCredentialsForProtectionSpace:completionHandler:]):
+ * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::clearPermanentCredentialsForProtectionSpace):
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::fetchDataAndApply):
+ (WebKit::computeWebProcessAccessTypeForDataRemoval):
+ (WebKit::WebsiteDataStore::removeData):
+
2019-07-09 Antoine Quint <[email protected]>
[Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (247269 => 247270)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-07-09 19:25:57 UTC (rev 247270)
@@ -455,6 +455,12 @@
ASSERT_NOT_REACHED();
}
+void NetworkProcess::clearPermanentCredentialsForProtectionSpace(const ProtectionSpace& protectionSpace, CompletionHandler<void()>&& completionHandler)
+{
+ WebCore::CredentialStorage::clearPermanentCredentialsForProtectionSpace(protectionSpace);
+ completionHandler();
+}
+
void NetworkProcess::addWebsiteDataStore(WebsiteDataStoreParameters&& parameters)
{
#if ENABLE(INDEXED_DATABASE)
@@ -1296,6 +1302,9 @@
for (auto& securityOrigin : securityOrigins)
callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::Credentials, 0 });
}
+ auto securityOrigins = WebCore::CredentialStorage::originsWithSessionCredentials();
+ for (auto& securityOrigin : securityOrigins)
+ callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::Credentials, 0 });
}
if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
@@ -1377,6 +1386,7 @@
if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
if (auto* session = storageSession(sessionID))
session->credentialStorage().clearCredentials();
+ WebCore::CredentialStorage::clearSessionCredentials();
}
auto clearTasksHandler = WTF::CallbackAggregator::create([this, callbackID] {
@@ -1514,6 +1524,7 @@
for (auto& originData : originDatas)
session->credentialStorage().removeCredentialsWithOrigin(originData);
}
+ WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originDatas);
}
// FIXME: Implement storage quota clearing for these origins.
@@ -1658,14 +1669,18 @@
}
#endif
- /*
- // FIXME: No API to delete credentials by origin
- HashSet<String> originsWithCredentials;
if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
- if (storageSession(sessionID))
- originsWithCredentials = storageSession(sessionID)->credentialStorage().originsWithCredentials();
+ if (auto* session = storageSession(sessionID)) {
+ auto origins = session->credentialStorage().originsWithCredentials();
+ auto originsToDelete = filterForRegistrableDomains(origins, domainsToDeleteAllButCookiesFor, callbackAggregator->m_domains);
+ for (auto& origin : originsToDelete)
+ session->credentialStorage().removeCredentialsWithOrigin(origin);
+ }
+
+ auto origins = WebCore::CredentialStorage::originsWithSessionCredentials();
+ auto originsToDelete = filterForRegistrableDomains(origins, domainsToDeleteAllButCookiesFor, callbackAggregator->m_domains);
+ WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originsToDelete);
}
- */
if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, domainsToDeleteAllButCookiesFor, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
@@ -2561,16 +2576,6 @@
}
#if !PLATFORM(COCOA)
-void NetworkProcess::originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&& completionHandler)
-{
- completionHandler(Vector<WebCore::SecurityOriginData>());
-}
-
-void NetworkProcess::removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&& completionHandler)
-{
- completionHandler();
-}
-
void NetworkProcess::initializeProcess(const AuxiliaryProcessInitializationParameters&)
{
}
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (247269 => 247270)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-07-09 19:25:57 UTC (rev 247270)
@@ -393,6 +393,7 @@
void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, uint64_t callbackID);
void clearCachedCredentials();
+ void clearPermanentCredentialsForProtectionSpace(const WebCore::ProtectionSpace&, CompletionHandler<void()>&&);
void setCacheStorageParameters(PAL::SessionID, String&& cacheStorageDirectory, SandboxExtension::Handle&&);
void initializeQuotaUsers(WebCore::StorageQuotaManager&, PAL::SessionID, const WebCore::ClientOrigin&);
@@ -436,9 +437,6 @@
#endif
void platformSyncAllCookies(CompletionHandler<void()>&&);
-
- void originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&&);
- void removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>& origins, CompletionHandler<void()>&&);
void registerURLSchemeAsSecure(const String&) const;
void registerURLSchemeAsBypassingContentSecurityPolicy(const String&) const;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (247269 => 247270)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-07-09 19:25:57 UTC (rev 247270)
@@ -38,6 +38,7 @@
#endif
ClearCachedCredentials()
+ ClearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace protectionSpace) -> () Async
AddWebsiteDataStore(struct WebKit::WebsiteDataStoreParameters websiteDataStoreParameters);
DestroySession(PAL::SessionID sessionID)
@@ -168,7 +169,5 @@
SetAdClickAttributionOverrideTimerForTesting(PAL::SessionID sessionID, bool value) -> () Async
SetAdClickAttributionConversionURLForTesting(PAL::SessionID sessionID, URL url) -> () Async
MarkAdClickAttributionsAsExpiredForTesting(PAL::SessionID sessionID) -> () Async
- OriginsWithPersistentCredentials() -> (Vector<WebCore::SecurityOriginData> origins) Async
- RemoveCredentialsWithOrigins(Vector<WebCore::SecurityOriginData> origins) -> () Async
GetLocalStorageOriginDetails(PAL::SessionID sessionID) -> (Vector<WebKit::LocalStorageDatabaseTracker::OriginDetails> details) Async
}
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (247269 => 247270)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2019-07-09 19:25:57 UTC (rev 247270)
@@ -212,31 +212,6 @@
}).get());
}
-void NetworkProcess::originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&& completionHandler)
-{
- completionHandler(WebCore::CredentialStorage::originsWithPersistentCredentials());
-}
-
-void NetworkProcess::removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>& origins, CompletionHandler<void()>&& completionHandler)
-{
- for (auto& origin : origins) {
- auto allCredentials = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials];
- for (NSURLProtectionSpace* space in allCredentials) {
- if (origin.protocol == String(space.protocol)
- && origin.host == String(space.host)
- && origin.port
- && *origin.port == space.port) {
- auto credentials = allCredentials[space];
- for (NSString* user in credentials) {
- auto credential = credentials[user];
- [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:credential forProtectionSpace:space];
- }
- }
- }
- }
- completionHandler();
-}
-
#if PLATFORM(MAC)
void NetworkProcess::setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier)
{
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm (247269 => 247270)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2019-07-09 19:25:57 UTC (rev 247270)
@@ -631,4 +631,11 @@
return _processPool->networkProcessHasEntitlementForTesting(entitlement);
}
+- (void)_clearPermanentCredentialsForProtectionSpace:(NSURLProtectionSpace *)protectionSpace completionHandler:(void(^)())completionHandler
+{
+ _processPool->clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace(protectionSpace), [completionHandler = makeBlockPtr(completionHandler)] {
+ completionHandler();
+ });
+}
+
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (247269 => 247270)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h 2019-07-09 19:25:57 UTC (rev 247270)
@@ -120,6 +120,7 @@
- (void)_registerURLSchemeServiceWorkersCanHandle:(NSString *)scheme WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
- (void)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid completionHandler:(void(^)(NSArray<NSString *> *))completionHandler WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
- (BOOL)_networkProcessHasEntitlementForTesting:(NSString *)entitlement WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+- (void)_clearPermanentCredentialsForProtectionSpace:(NSURLProtectionSpace *)protectionSpace completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, getter=_isCookieStoragePartitioningEnabled, setter=_setCookieStoragePartitioningEnabled:) BOOL _cookieStoragePartitioningEnabled WK_API_DEPRECATED("Partitioned cookies are no longer supported", macos(10.12.3, 10.14.4), ios(10.3, 12.2));
@property (nonatomic, getter=_isStorageAccessAPIEnabled, setter=_setStorageAccessAPIEnabled:) BOOL _storageAccessAPIEnabled WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (247269 => 247270)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-07-09 19:25:57 UTC (rev 247270)
@@ -1744,6 +1744,12 @@
m_networkProcess->send(Messages::NetworkProcess::ClearCachedCredentials(), 0);
}
+void WebProcessPool::clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace&& protectionSpace, CompletionHandler<void()>&& completionHandler)
+{
+ if (m_networkProcess)
+ m_networkProcess->sendWithAsyncReply(Messages::NetworkProcess::ClearPermanentCredentialsForProtectionSpace(protectionSpace), WTFMove(completionHandler));
+}
+
void WebProcessPool::terminateNetworkProcess()
{
if (!m_networkProcess)
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (247269 => 247270)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-07-09 19:25:57 UTC (rev 247270)
@@ -310,6 +310,7 @@
void setAllowsAnySSLCertificateForWebSocket(bool);
void clearCachedCredentials();
+ void clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace&&, CompletionHandler<void()>&&);
void terminateNetworkProcess();
void sendNetworkProcessWillSuspendImminently();
void sendNetworkProcessDidResume();
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (247269 => 247270)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-07-09 19:25:57 UTC (rev 247270)
@@ -520,24 +520,6 @@
});
}
-#if PLATFORM(COCOA)
- if (dataTypes.contains(WebsiteDataType::Credentials) && isPersistent()) {
- for (auto& processPool : processPools()) {
- if (!processPool->networkProcess())
- continue;
-
- callbackAggregator->addPendingCallback();
- WTF::CompletionHandler<void(Vector<WebCore::SecurityOriginData>&&)> completionHandler = [callbackAggregator](Vector<WebCore::SecurityOriginData>&& origins) mutable {
- WebsiteData websiteData;
- for (auto& origin : origins)
- websiteData.entries.append(WebsiteData::Entry { origin, WebsiteDataType::Credentials, 0 });
- callbackAggregator->removePendingCallback(WTFMove(websiteData));
- };
- processPool->networkProcess()->sendWithAsyncReply(Messages::NetworkProcess::OriginsWithPersistentCredentials(), WTFMove(completionHandler));
- }
- }
-#endif
-
#if ENABLE(NETSCAPE_PLUGIN_API)
if (dataTypes.contains(WebsiteDataType::PlugInData) && isPersistent()) {
class State {
@@ -644,9 +626,6 @@
if (dataTypes.contains(WebsiteDataType::MemoryCache))
processAccessType = std::max(processAccessType, ProcessAccessType::OnlyIfLaunched);
- if (dataTypes.contains(WebsiteDataType::Credentials))
- processAccessType = std::max(processAccessType, ProcessAccessType::OnlyIfLaunched);
-
return processAccessType;
}
@@ -1093,19 +1072,6 @@
});
}
- if (dataTypes.contains(WebsiteDataType::Credentials) && isPersistent()) {
- for (auto& processPool : processPools()) {
- if (!processPool->networkProcess())
- continue;
-
- callbackAggregator->addPendingCallback();
- WTF::CompletionHandler<void()> completionHandler = [callbackAggregator]() mutable {
- callbackAggregator->removePendingCallback();
- };
- processPool->networkProcess()->sendWithAsyncReply(Messages::NetworkProcess::RemoveCredentialsWithOrigins(origins), WTFMove(completionHandler));
- }
- }
-
#if ENABLE(NETSCAPE_PLUGIN_API)
if (dataTypes.contains(WebsiteDataType::PlugInData) && isPersistent()) {
Vector<String> hostNames;
Modified: trunk/Tools/ChangeLog (247269 => 247270)
--- trunk/Tools/ChangeLog 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Tools/ChangeLog 2019-07-09 19:25:57 UTC (rev 247270)
@@ -1,3 +1,20 @@
+2019-07-09 Sihui Liu <[email protected]>
+
+ Only allow fetching and removing session credentials from WebsiteDataStore
+ https://bugs.webkit.org/show_bug.cgi?id=199385
+ <rdar://problem/52622080>
+
+ Reviewed by Alex Christensen.
+
+ removeDataOfTypes will no longer remove persistent credentials. We should clear persistent credentials using
+ the new SPI after each test that creates persistent credentials, otherwise the later tests may use credentials
+ left by previous tests and didReceiveAuthenticationChallenge will not be invoked.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
+ (TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
+ (TestWebKitAPI::TEST):
+
2019-07-09 Alex Christensen <[email protected]>
When parsing an IPv4 address, wait until after deciding it is indeed an IPv4 address before reporting syntax violations
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm (247269 => 247270)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm 2019-07-09 19:25:57 UTC (rev 247270)
@@ -103,6 +103,14 @@
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]];
Util::run(&navigationFinished);
+
+ // Clear persistent credentials created by this test.
+ NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:@"127.0.0.1" port:server.port() protocol:NSURLProtectionSpaceHTTP realm:@"testrealm" authenticationMethod:NSURLAuthenticationMethodHTTPBasic] autorelease];
+ __block bool removedCredential = false;
+ [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace completionHandler:^{
+ removedCredential = true;
+ }];
+ Util::run(&removedCredential);
}
@interface ClientCertificateDelegate : NSObject <WKNavigationDelegate> {
@@ -198,13 +206,12 @@
[webView loadRequest:request.get()];
Util::run(&navigationFinished);
EXPECT_TRUE(receivedSecondChallenge);
-
+
+ // Clear persistent credentials created by this test.
+ NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:@"127.0.0.1" port:server.port() protocol:NSURLProtectionSpaceHTTP realm:@"testrealm" authenticationMethod:NSURLAuthenticationMethodHTTPBasic] autorelease];
__block bool removedCredential = false;
- WKWebsiteDataStore *websiteDataStore = [webView configuration].websiteDataStore;
- [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
- [websiteDataStore removeDataOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] forDataRecords:dataRecords completionHandler:^(void) {
- removedCredential = true;
- }];
+ [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace completionHandler:^{
+ removedCredential = true;
}];
Util::run(&removedCredential);
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm (247269 => 247270)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2019-07-09 19:15:04 UTC (rev 247269)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2019-07-09 19:25:57 UTC (rev 247270)
@@ -92,7 +92,7 @@
readyToContinue = false;
[[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
- ASSERT_EQ(0u, dataRecords.count);
+ EXPECT_EQ(0u, dataRecords.count);
readyToContinue = true;
}];
TestWebKitAPI::Util::run(&readyToContinue);
@@ -139,45 +139,7 @@
TEST(WKWebsiteDataStore, FetchPersistentCredentials)
{
TCPServer server(TCPServer::respondWithChallengeThenOK);
-
- usePersistentCredentialStorage = true;
- auto websiteDataStore = [WKWebsiteDataStore defaultDataStore];
- auto navigationDelegate = adoptNS([[NavigationTestDelegate alloc] init]);
- auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
- [webView setNavigationDelegate:navigationDelegate.get()];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]];
- [navigationDelegate waitForDidFinishNavigation];
- __block bool done = false;
- [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
- int credentialCount = dataRecords.count;
- ASSERT_GT(credentialCount, 0);
- bool foundExpectedRecord = false;
- for (WKWebsiteDataRecord *record in dataRecords) {
- auto name = [record displayName];
- if ([name isEqualToString:@"127.0.0.1"]) {
- foundExpectedRecord = true;
- break;
- }
- }
- EXPECT_TRUE(foundExpectedRecord);
- done = true;
- }];
- TestWebKitAPI::Util::run(&done);
-
- __block bool removedCredential = false;
- [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
- [websiteDataStore removeDataOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] forDataRecords:dataRecords completionHandler:^(void) {
- removedCredential = true;
- }];
- }];
- TestWebKitAPI::Util::run(&removedCredential);
-}
-
-TEST(WKWebsiteDataStore, RemovePersistentCredentials)
-{
- TCPServer server(TCPServer::respondWithChallengeThenOK);
-
usePersistentCredentialStorage = true;
auto websiteDataStore = [WKWebsiteDataStore defaultDataStore];
auto navigationDelegate = adoptNS([[NavigationTestDelegate alloc] init]);
@@ -187,42 +149,20 @@
[navigationDelegate waitForDidFinishNavigation];
__block bool done = false;
- __block RetainPtr<WKWebsiteDataRecord> expectedRecord;
[websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
int credentialCount = dataRecords.count;
- ASSERT_GT(credentialCount, 0);
- for (WKWebsiteDataRecord *record in dataRecords) {
- auto name = [record displayName];
- if ([name isEqualToString:@"127.0.0.1"]) {
- expectedRecord = record;
- break;
- }
- }
- EXPECT_TRUE(expectedRecord);
+ EXPECT_EQ(credentialCount, 0);
done = true;
}];
TestWebKitAPI::Util::run(&done);
- done = false;
- [websiteDataStore removeDataOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] forDataRecords:[NSArray arrayWithObject:expectedRecord.get()] completionHandler:^(void) {
- done = true;
+ // Clear persistent credentials created by this test.
+ NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:@"127.0.0.1" port:server.port() protocol:NSURLProtectionSpaceHTTP realm:@"testrealm" authenticationMethod:NSURLAuthenticationMethodHTTPBasic] autorelease];
+ __block bool removedCredential = false;
+ [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace completionHandler:^{
+ removedCredential = true;
}];
- TestWebKitAPI::Util::run(&done);
-
- done = false;
- [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
- bool foundLocalHostRecord = false;
- for (WKWebsiteDataRecord *record in dataRecords) {
- auto name = [record displayName];
- if ([name isEqualToString:@"127.0.0.1"]) {
- foundLocalHostRecord = true;
- break;
- }
- }
- EXPECT_FALSE(foundLocalHostRecord);
- done = true;
- }];
- TestWebKitAPI::Util::run(&done);
+ Util::run(&removedCredential);
}
TEST(WKWebsiteDataStore, RemoveNonPersistentCredentials)