Changeset 247162 in webkit
- Timestamp:
- Jul 5, 2019 9:59:42 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247159 r247162 1 2019-07-05 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r247123. 4 5 Caused TestWebKitAPI.Challenge.BasicProposedCredential to 6 fail. 7 8 Reverted changeset: 9 10 "Only allow fetching and removing session credentials from 11 WebsiteDataStore" 12 https://bugs.webkit.org/show_bug.cgi?id=199385 13 https://trac.webkit.org/changeset/247123 14 1 15 2019-07-05 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Source/WebCore/platform/network/CredentialStorage.cpp
r247123 r247162 103 103 } 104 104 105 HashSet<SecurityOriginData> CredentialStorage::originsWithCredentials() const105 Vector<SecurityOriginData> CredentialStorage::originsWithCredentials() const 106 106 { 107 HashSet<SecurityOriginData> origins;107 Vector<SecurityOriginData> origins; 108 108 for (auto& keyValuePair : m_protectionSpaceToCredentialMap) { 109 109 auto& protectionSpace = keyValuePair.key.second; … … 130 130 131 131 SecurityOriginData origin { protocol, protectionSpace.host(), static_cast<uint16_t>(protectionSpace.port())}; 132 origins.a dd(WTFMove(origin));132 origins.append(WTFMove(origin)); 133 133 } 134 134 return origins; … … 188 188 } 189 189 190 #if !PLATFORM(COCOA)191 HashSet<SecurityOriginData> CredentialStorage::originsWithSessionCredentials()192 {193 return { };194 }195 196 void CredentialStorage::removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>&)197 {198 }199 200 void CredentialStorage::clearSessionCredentials()201 {202 }203 #endif204 205 190 } // namespace WebCore -
trunk/Source/WebCore/platform/network/CredentialStorage.h
r247123 r247162 46 46 WEBCORE_EXPORT void removeCredentialsWithOrigin(const SecurityOriginData&); 47 47 48 // OS credentialstorage.48 // OS persistent storage. 49 49 WEBCORE_EXPORT static Credential getFromPersistentStorage(const ProtectionSpace&); 50 WEBCORE_EXPORT static HashSet<SecurityOriginData> originsWithSessionCredentials(); 51 WEBCORE_EXPORT static void removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>& origins); 52 WEBCORE_EXPORT static void clearSessionCredentials(); 50 WEBCORE_EXPORT static Vector<SecurityOriginData> originsWithPersistentCredentials(); 53 51 54 52 WEBCORE_EXPORT void clearCredentials(); … … 59 57 WEBCORE_EXPORT Credential get(const String&, const URL&); 60 58 61 WEBCORE_EXPORT HashSet<SecurityOriginData> originsWithCredentials() const;59 WEBCORE_EXPORT Vector<SecurityOriginData> originsWithCredentials() const; 62 60 63 61 private: -
trunk/Source/WebCore/platform/network/mac/CredentialStorageMac.mm
r247123 r247162 39 39 } 40 40 41 HashSet<SecurityOriginData> CredentialStorage::originsWithSessionCredentials()41 Vector<WebCore::SecurityOriginData> CredentialStorage::originsWithPersistentCredentials() 42 42 { 43 HashSet<SecurityOriginData> origins;43 Vector<WebCore::SecurityOriginData> origins; 44 44 auto allCredentials = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials]; 45 for (NSURLProtectionSpace* key in allCredentials.keyEnumerator) { 46 for (NSURLProtectionSpace* space in allCredentials) { 47 auto credentials = allCredentials[space]; 48 for (NSString* user in credentials) { 49 if (credentials[user].persistence == NSURLCredentialPersistenceForSession) { 50 origins.add(WebCore::SecurityOriginData { String(key.protocol), String(key.host), key.port }); 51 break; 52 } 53 } 54 } 55 } 45 for (NSURLProtectionSpace* key in allCredentials.keyEnumerator) 46 origins.append(WebCore::SecurityOriginData { String(key.protocol), String(key.host), key.port }); 56 47 return origins; 57 48 } 58 49 59 void CredentialStorage::removeSessionCredentialsWithOrigins(const Vector<SecurityOriginData>& origins)60 {61 auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];62 auto allCredentials = [sharedStorage allCredentials];63 for (auto& origin : origins) {64 for (NSURLProtectionSpace* space in allCredentials) {65 if (origin.protocol == String(space.protocol)66 && origin.host == String(space.host)67 && origin.port68 && *origin.port == space.port) {69 auto credentials = allCredentials[space];70 for (NSString* user in credentials) {71 auto credential = credentials[user];72 if (credential.persistence == NSURLCredentialPersistenceForSession)73 [sharedStorage removeCredential:credential forProtectionSpace:space];74 }75 }76 }77 }78 }79 80 void CredentialStorage::clearSessionCredentials()81 {82 auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];83 auto allCredentials = [sharedStorage allCredentials];84 for (NSURLProtectionSpace* space in allCredentials.keyEnumerator) {85 auto credentials = allCredentials[space];86 for (NSString* user in credentials) {87 auto credential = credentials[user];88 if (credential.persistence == NSURLCredentialPersistenceForSession)89 [sharedStorage removeCredential:credential forProtectionSpace:space];90 }91 }92 }93 94 50 } // namespace WebCore -
trunk/Source/WebKit/ChangeLog
r247161 r247162 1 2019-07-05 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r247123. 4 5 Caused TestWebKitAPI.Challenge.BasicProposedCredential to 6 fail. 7 8 Reverted changeset: 9 10 "Only allow fetching and removing session credentials from 11 WebsiteDataStore" 12 https://bugs.webkit.org/show_bug.cgi?id=199385 13 https://trac.webkit.org/changeset/247123 14 1 15 2019-07-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r247123 r247162 1299 1299 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::Credentials, 0 }); 1300 1300 } 1301 auto securityOrigins = WebCore::CredentialStorage::originsWithSessionCredentials();1302 for (auto& securityOrigin : securityOrigins)1303 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::Credentials, 0 });1304 1301 } 1305 1302 … … 1383 1380 if (auto* session = storageSession(sessionID)) 1384 1381 session->credentialStorage().clearCredentials(); 1385 WebCore::CredentialStorage::clearSessionCredentials();1386 1382 } 1387 1383 … … 1521 1517 session->credentialStorage().removeCredentialsWithOrigin(originData); 1522 1518 } 1523 WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originDatas);1524 1519 } 1525 1520 … … 1666 1661 #endif 1667 1662 1663 /* 1664 // FIXME: No API to delete credentials by origin 1665 HashSet<String> originsWithCredentials; 1668 1666 if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { 1669 if (auto* session = storageSession(sessionID)) { 1670 auto origins = session->credentialStorage().originsWithCredentials(); 1671 auto originsToDelete = filterForRegistrableDomains(origins, domainsToDeleteAllButCookiesFor, callbackAggregator->m_domains); 1672 for (auto& origin : originsToDelete) 1673 session->credentialStorage().removeCredentialsWithOrigin(origin); 1674 } 1675 1676 auto origins = WebCore::CredentialStorage::originsWithSessionCredentials(); 1677 auto originsToDelete = filterForRegistrableDomains(origins, domainsToDeleteAllButCookiesFor, callbackAggregator->m_domains); 1678 WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originsToDelete); 1679 } 1667 if (storageSession(sessionID)) 1668 originsWithCredentials = storageSession(sessionID)->credentialStorage().originsWithCredentials(); 1669 } 1670 */ 1680 1671 1681 1672 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { … … 2573 2564 2574 2565 #if !PLATFORM(COCOA) 2566 void NetworkProcess::originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&& completionHandler) 2567 { 2568 completionHandler(Vector<WebCore::SecurityOriginData>()); 2569 } 2570 2571 void NetworkProcess::removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&& completionHandler) 2572 { 2573 completionHandler(); 2574 } 2575 2575 2576 void NetworkProcess::initializeProcess(const AuxiliaryProcessInitializationParameters&) 2576 2577 { -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r247123 r247162 437 437 438 438 void platformSyncAllCookies(CompletionHandler<void()>&&); 439 440 void originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&&); 441 void removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>& origins, CompletionHandler<void()>&&); 439 442 440 443 void registerURLSchemeAsSecure(const String&) const; -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r247123 r247162 169 169 SetAdClickAttributionConversionURLForTesting(PAL::SessionID sessionID, URL url) -> () Async 170 170 MarkAdClickAttributionsAsExpiredForTesting(PAL::SessionID sessionID) -> () Async 171 OriginsWithPersistentCredentials() -> (Vector<WebCore::SecurityOriginData> origins) Async 172 RemoveCredentialsWithOrigins(Vector<WebCore::SecurityOriginData> origins) -> () Async 171 173 GetLocalStorageOriginDetails(PAL::SessionID sessionID) -> (Vector<WebKit::LocalStorageDatabaseTracker::OriginDetails> details) Async 172 174 } -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r247123 r247162 213 213 } 214 214 215 void NetworkProcess::originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&& completionHandler) 216 { 217 completionHandler(WebCore::CredentialStorage::originsWithPersistentCredentials()); 218 } 219 220 void NetworkProcess::removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>& origins, CompletionHandler<void()>&& completionHandler) 221 { 222 for (auto& origin : origins) { 223 auto allCredentials = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials]; 224 for (NSURLProtectionSpace* space in allCredentials) { 225 if (origin.protocol == String(space.protocol) 226 && origin.host == String(space.host) 227 && origin.port 228 && *origin.port == space.port) { 229 auto credentials = allCredentials[space]; 230 for (NSString* user in credentials) { 231 auto credential = credentials[user]; 232 [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:credential forProtectionSpace:space]; 233 } 234 } 235 } 236 } 237 completionHandler(); 238 } 239 215 240 #if PLATFORM(MAC) 216 241 void NetworkProcess::setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier) -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r247146 r247162 521 521 } 522 522 523 #if PLATFORM(COCOA) 524 if (dataTypes.contains(WebsiteDataType::Credentials) && isPersistent()) { 525 for (auto& processPool : processPools()) { 526 if (!processPool->networkProcess()) 527 continue; 528 529 callbackAggregator->addPendingCallback(); 530 WTF::CompletionHandler<void(Vector<WebCore::SecurityOriginData>&&)> completionHandler = [callbackAggregator](Vector<WebCore::SecurityOriginData>&& origins) mutable { 531 WebsiteData websiteData; 532 for (auto& origin : origins) 533 websiteData.entries.append(WebsiteData::Entry { origin, WebsiteDataType::Credentials, 0 }); 534 callbackAggregator->removePendingCallback(WTFMove(websiteData)); 535 }; 536 processPool->networkProcess()->sendWithAsyncReply(Messages::NetworkProcess::OriginsWithPersistentCredentials(), WTFMove(completionHandler)); 537 } 538 } 539 #endif 540 523 541 #if ENABLE(NETSCAPE_PLUGIN_API) 524 542 if (dataTypes.contains(WebsiteDataType::PlugInData) && isPersistent()) { … … 627 645 processAccessType = std::max(processAccessType, ProcessAccessType::OnlyIfLaunched); 628 646 647 if (dataTypes.contains(WebsiteDataType::Credentials)) 648 processAccessType = std::max(processAccessType, ProcessAccessType::OnlyIfLaunched); 649 629 650 return processAccessType; 630 651 } … … 1073 1094 } 1074 1095 1096 if (dataTypes.contains(WebsiteDataType::Credentials) && isPersistent()) { 1097 for (auto& processPool : processPools()) { 1098 if (!processPool->networkProcess()) 1099 continue; 1100 1101 callbackAggregator->addPendingCallback(); 1102 WTF::CompletionHandler<void()> completionHandler = [callbackAggregator]() mutable { 1103 callbackAggregator->removePendingCallback(); 1104 }; 1105 processPool->networkProcess()->sendWithAsyncReply(Messages::NetworkProcess::RemoveCredentialsWithOrigins(origins), WTFMove(completionHandler)); 1106 } 1107 } 1108 1075 1109 #if ENABLE(NETSCAPE_PLUGIN_API) 1076 1110 if (dataTypes.contains(WebsiteDataType::PlugInData) && isPersistent()) { -
trunk/Tools/ChangeLog
r247158 r247162 1 2019-07-05 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r247123. 4 5 Caused TestWebKitAPI.Challenge.BasicProposedCredential to 6 fail. 7 8 Reverted changeset: 9 10 "Only allow fetching and removing session credentials from 11 WebsiteDataStore" 12 https://bugs.webkit.org/show_bug.cgi?id=199385 13 https://trac.webkit.org/changeset/247123 14 1 15 2019-07-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm
r247123 r247162 93 93 readyToContinue = false; 94 94 [[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 95 EXPECT_EQ(0u, dataRecords.count);95 ASSERT_EQ(0u, dataRecords.count); 96 96 readyToContinue = true; 97 97 }]; … … 140 140 { 141 141 TCPServer server(TCPServer::respondWithChallengeThenOK); 142 142 143 143 usePersistentCredentialStorage = true; 144 144 auto websiteDataStore = [WKWebsiteDataStore defaultDataStore]; … … 152 152 [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 153 153 int credentialCount = dataRecords.count; 154 EXPECT_EQ(credentialCount, 0); 154 ASSERT_GT(credentialCount, 0); 155 bool foundExpectedRecord = false; 156 for (WKWebsiteDataRecord *record in dataRecords) { 157 auto name = [record displayName]; 158 if ([name isEqualToString:@"127.0.0.1"]) { 159 foundExpectedRecord = true; 160 break; 161 } 162 } 163 EXPECT_TRUE(foundExpectedRecord); 164 done = true; 165 }]; 166 TestWebKitAPI::Util::run(&done); 167 168 __block bool removedCredential = false; 169 [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 170 [websiteDataStore removeDataOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] forDataRecords:dataRecords completionHandler:^(void) { 171 removedCredential = true; 172 }]; 173 }]; 174 TestWebKitAPI::Util::run(&removedCredential); 175 } 176 177 TEST(WKWebsiteDataStore, RemovePersistentCredentials) 178 { 179 TCPServer server(TCPServer::respondWithChallengeThenOK); 180 181 usePersistentCredentialStorage = true; 182 auto websiteDataStore = [WKWebsiteDataStore defaultDataStore]; 183 auto navigationDelegate = adoptNS([[NavigationTestDelegate alloc] init]); 184 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); 185 [webView setNavigationDelegate:navigationDelegate.get()]; 186 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]]; 187 [navigationDelegate waitForDidFinishNavigation]; 188 189 __block bool done = false; 190 __block RetainPtr<WKWebsiteDataRecord> expectedRecord; 191 [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 192 int credentialCount = dataRecords.count; 193 ASSERT_GT(credentialCount, 0); 194 for (WKWebsiteDataRecord *record in dataRecords) { 195 auto name = [record displayName]; 196 if ([name isEqualToString:@"127.0.0.1"]) { 197 expectedRecord = record; 198 break; 199 } 200 } 201 EXPECT_TRUE(expectedRecord); 202 done = true; 203 }]; 204 TestWebKitAPI::Util::run(&done); 205 206 done = false; 207 [websiteDataStore removeDataOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] forDataRecords:[NSArray arrayWithObject:expectedRecord.get()] completionHandler:^(void) { 208 done = true; 209 }]; 210 TestWebKitAPI::Util::run(&done); 211 212 done = false; 213 [websiteDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:_WKWebsiteDataTypeCredentials] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 214 bool foundLocalHostRecord = false; 215 for (WKWebsiteDataRecord *record in dataRecords) { 216 auto name = [record displayName]; 217 if ([name isEqualToString:@"127.0.0.1"]) { 218 foundLocalHostRecord = true; 219 break; 220 } 221 } 222 EXPECT_FALSE(foundLocalHostRecord); 155 223 done = true; 156 224 }];
Note: See TracChangeset
for help on using the changeset viewer.