Bug 1649673 - Isolate speculative connections per first-party when privacy.partition.network_state is set to true, r=mayhemer,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D81810
This commit is contained in:
Andrea Marchesini 2020-07-10 11:54:34 +00:00
Родитель b8cba0987b
Коммит 7e5c0a3709
3 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -28,6 +28,7 @@
#include "mozilla/Sprintf.h" #include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_network.h" #include "mozilla/StaticPrefs_network.h"
#include "mozilla/StaticPrefs_privacy.h" #include "mozilla/StaticPrefs_privacy.h"
#include "mozilla/StoragePrincipalHelper.h"
#include "nsAsyncRedirectVerifyHelper.h" #include "nsAsyncRedirectVerifyHelper.h"
#include "nsSocketTransportService2.h" #include "nsSocketTransportService2.h"
#include "nsAlgorithm.h" #include "nsAlgorithm.h"
@ -2508,14 +2509,16 @@ nsresult nsHttpHandler::SpeculativeConnectInternal(
OriginAttributes originAttributes; OriginAttributes originAttributes;
// If the principal is given, we use the originAttributes from this // If the principal is given, we use the originAttributes from this
// principal. Otherwise, we use the originAttributes from the // principal. Otherwise, we use the originAttributes from the loadContext.
// loadContext.
if (aPrincipal) { if (aPrincipal) {
originAttributes = aPrincipal->OriginAttributesRef(); originAttributes = aPrincipal->OriginAttributesRef();
} else if (loadContext) { } else if (loadContext) {
loadContext->GetOriginAttributes(originAttributes); loadContext->GetOriginAttributes(originAttributes);
} }
StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
aURI, originAttributes);
nsCOMPtr<nsIURI> clone; nsCOMPtr<nsIURI> clone;
if (NS_SUCCEEDED(sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI, if (NS_SUCCEEDED(sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI,
flags, originAttributes, nullptr, nullptr, flags, originAttributes, nullptr, nullptr,

Просмотреть файл

@ -310,4 +310,14 @@ void StoragePrincipalHelper::GetOriginAttributesForNetworkState(
aAttributes = aDocument->PartitionedPrincipal()->OriginAttributesRef(); aAttributes = aDocument->PartitionedPrincipal()->OriginAttributesRef();
} }
// static
void StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
nsIURI* aFirstPartyURI, OriginAttributes& aAttributes) {
if (!StaticPrefs::privacy_partition_network_state()) {
return;
}
aAttributes.SetPartitionKey(aFirstPartyURI);
}
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -266,6 +266,8 @@ class StoragePrincipalHelper final {
OriginAttributes& aAttributes); OriginAttributes& aAttributes);
static void GetOriginAttributesForNetworkState(dom::Document* aDocument, static void GetOriginAttributesForNetworkState(dom::Document* aDocument,
OriginAttributes& aAttributes); OriginAttributes& aAttributes);
static void UpdateOriginAttributesForNetworkState(
nsIURI* aFirstPartyURI, OriginAttributes& aAttributes);
}; };
} // namespace mozilla } // namespace mozilla