Bug 1330467 - part 1. Don't strip first party domain from permissions key; r=johannh,Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D19922

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Liang-Heng Chen 2019-05-17 13:23:16 +00:00
Родитель 0c7539d4de
Коммит c42628e988
3 изменённых файлов: 10 добавлений и 16 удалений

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

@ -31,8 +31,7 @@ already_AddRefed<nsIPrincipal> nsPermission::ClonePrincipalForPermission(
MOZ_ASSERT(aPrincipal);
mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
nsAutoCString originNoSuffix;
nsresult rv = aPrincipal->GetOriginNoSuffix(originNoSuffix);

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

@ -23,8 +23,7 @@ class nsPermission : public nsIPermission {
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime);
// This method creates a new nsIPrincipal with a stripped OriginAttributes (no
// userContextId, and no FirstPartyDomain) and a codebase equal to the origin
// of 'aPrincipal'.
// userContextId) and a codebase equal to the origin of 'aPrincipal'.
static already_AddRefed<nsIPrincipal> ClonePrincipalForPermission(
nsIPrincipal* aPrincipal);

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

@ -163,9 +163,8 @@ nsresult GetOriginFromPrincipal(nsIPrincipal* aPrincipal, nsACString& aOrigin) {
// changes the suffix being hashed.
attrs.mPrivateBrowsingId = 0;
// Disable userContext and firstParty isolation for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
// Disable userContext for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
attrs.CreateSuffix(suffix);
aOrigin.Append(suffix);
@ -185,9 +184,8 @@ nsresult GetPrincipalFromOrigin(const nsACString& aOrigin,
// changes the suffix being hashed.
attrs.mPrivateBrowsingId = 0;
// Disable userContext and firstParty isolation for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
// Disable userContext for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
@ -278,9 +276,8 @@ already_AddRefed<nsIPrincipal> GetNextSubDomainPrincipal(
// Copy the attributes over
mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
// Disable userContext and firstParty isolation for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
// Disable userContext for permissions.
attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs);
@ -3281,9 +3278,8 @@ void nsPermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
// changes the suffix being hashed.
attrs.mPrivateBrowsingId = 0;
// Disable userContext and firstParty isolation for permissions.
attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID |
OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
// Disable userContext for permissions.
attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID);
#ifdef DEBUG
// Parse the origin string into a principal, and extract some useful