2001-09-25 05:03:58 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-01 04:54:35 +04:00
|
|
|
|
|
|
|
/* Defines the abstract interface for a principal. */
|
|
|
|
|
2019-05-22 02:14:27 +03:00
|
|
|
#include "nsIContentSecurityPolicy.idl"
|
2001-07-31 23:05:34 +04:00
|
|
|
#include "nsISerializable.idl"
|
2019-10-17 16:54:41 +03:00
|
|
|
#include "nsIAboutModule.idl"
|
2020-03-05 16:42:13 +03:00
|
|
|
#include "nsIReferrerInfo.idl"
|
2020-04-27 13:54:47 +03:00
|
|
|
interface nsIChannel;
|
2020-05-19 17:51:40 +03:00
|
|
|
#include "mozIDOMWindow.idl"
|
1999-09-01 04:54:35 +04:00
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
%{C++
|
|
|
|
struct JSPrincipals;
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTArray.h"
|
2019-09-24 10:56:40 +03:00
|
|
|
#include "nsString.h"
|
2017-02-22 14:19:03 +03:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2016-12-19 13:30:06 +03:00
|
|
|
namespace mozilla {
|
2017-01-12 19:38:48 +03:00
|
|
|
class OriginAttributes;
|
2016-12-19 13:30:06 +03:00
|
|
|
}
|
2017-02-22 14:19:03 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Some methods have a fast path for the case when we're comparing a principal
|
|
|
|
* to itself. The situation may happen for example with about:blank documents.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DECL_FAST_INLINE_HELPER(method_) \
|
|
|
|
inline bool method_(nsIPrincipal* aOther) \
|
|
|
|
{ \
|
|
|
|
mozilla::DebugOnly<bool> val = false; \
|
|
|
|
MOZ_ASSERT_IF(this == aOther, \
|
|
|
|
NS_SUCCEEDED(method_(aOther, &val)) && val); \
|
|
|
|
\
|
|
|
|
bool retVal = false; \
|
|
|
|
return \
|
|
|
|
this == aOther || \
|
|
|
|
(NS_SUCCEEDED(method_(aOther, &retVal)) && retVal); \
|
|
|
|
}
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
%}
|
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
interface nsIURI;
|
|
|
|
|
2003-11-03 07:26:55 +03:00
|
|
|
[ptr] native JSContext(JSContext);
|
1999-08-20 13:51:02 +04:00
|
|
|
[ptr] native JSPrincipals(JSPrincipals);
|
2017-10-11 01:00:16 +03:00
|
|
|
[ref] native PrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>);
|
2017-01-12 19:38:48 +03:00
|
|
|
[ref] native const_OriginAttributes(const mozilla::OriginAttributes);
|
2020-03-05 16:42:13 +03:00
|
|
|
native ReferrerPolicy(mozilla::dom::ReferrerPolicy);
|
1999-07-24 07:58:23 +04:00
|
|
|
|
2017-02-04 01:56:13 +03:00
|
|
|
[scriptable, builtinclass, uuid(f75f502d-79fd-48be-a079-e5a7b8f80c8b)]
|
2003-07-24 09:15:20 +04:00
|
|
|
interface nsIPrincipal : nsISerializable
|
|
|
|
{
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Returns whether the other principal is equivalent to this principal.
|
2012-10-22 10:29:56 +04:00
|
|
|
* Principals are considered equal if they are the same principal, or
|
|
|
|
* they have the same origin.
|
2003-10-22 02:11:49 +04:00
|
|
|
*/
|
|
|
|
boolean equals(in nsIPrincipal other);
|
|
|
|
|
2020-04-23 16:11:56 +03:00
|
|
|
/**
|
|
|
|
* Returns whether the other principal is equivalent to this principal
|
|
|
|
* for permission purposes
|
|
|
|
* Matches {originAttributes ,equalsURIForPermission}
|
|
|
|
*/
|
|
|
|
|
|
|
|
boolean equalsForPermission(in nsIPrincipal other, in bool aExactHost);
|
|
|
|
|
2014-02-14 06:57:34 +04:00
|
|
|
/**
|
2014-02-14 06:57:36 +04:00
|
|
|
* Like equals, but takes document.domain changes into account.
|
2014-02-14 06:57:34 +04:00
|
|
|
*/
|
|
|
|
boolean equalsConsideringDomain(in nsIPrincipal other);
|
|
|
|
|
2013-05-04 01:47:09 +04:00
|
|
|
%{C++
|
2017-02-22 14:19:03 +03:00
|
|
|
DECL_FAST_INLINE_HELPER(Equals)
|
|
|
|
DECL_FAST_INLINE_HELPER(EqualsConsideringDomain)
|
2013-05-04 01:47:09 +04:00
|
|
|
%}
|
|
|
|
|
2020-01-22 20:14:08 +03:00
|
|
|
/*
|
|
|
|
* Returns whether the Principals URI is equal to the other URI
|
|
|
|
*/
|
2020-02-24 20:04:45 +03:00
|
|
|
boolean equalsURI(in nsIURI aOtherURI);
|
2020-01-22 20:14:08 +03:00
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
/**
|
|
|
|
* Returns a hash value for the principal.
|
|
|
|
*/
|
2018-11-20 04:17:52 +03:00
|
|
|
[notxpcom, nostdcall] readonly attribute unsigned long hashValue;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
2019-07-08 19:37:45 +03:00
|
|
|
* The principal URI to which this principal pertains. This is
|
2003-10-22 02:11:49 +04:00
|
|
|
* generally the document URI.
|
|
|
|
*/
|
2019-01-10 08:44:33 +03:00
|
|
|
[infallible] readonly attribute nsIURI URI;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The domain URI to which this principal pertains.
|
2015-09-24 02:36:04 +03:00
|
|
|
* This is null unless script successfully sets document.domain to our URI
|
|
|
|
* or a superdomain of our URI.
|
2003-10-22 02:11:49 +04:00
|
|
|
* Setting this has no effect on the URI.
|
2015-09-24 02:36:04 +03:00
|
|
|
* See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Changing_origin
|
2003-10-22 02:11:49 +04:00
|
|
|
*/
|
2006-02-17 19:12:17 +03:00
|
|
|
[noscript] attribute nsIURI domain;
|
2003-10-22 02:11:49 +04:00
|
|
|
|
2005-07-09 03:26:36 +04:00
|
|
|
/**
|
|
|
|
* Returns whether the other principal is equal to or weaker than this
|
2012-10-22 10:29:56 +04:00
|
|
|
* principal. Principals are equal if they are the same object or they
|
|
|
|
* have the same origin.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* Thus a principal always subsumes itself.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* The system principal subsumes itself and all other principals.
|
2005-07-09 03:26:36 +04:00
|
|
|
*
|
2006-04-03 02:00:08 +04:00
|
|
|
* A null principal (corresponding to an unknown, hence assumed minimally
|
|
|
|
* privileged, security context) is not equal to any other principal
|
|
|
|
* (including other null principals), and therefore does not subsume
|
|
|
|
* anything but itself.
|
2005-07-09 03:26:36 +04:00
|
|
|
*/
|
2010-12-22 16:58:22 +03:00
|
|
|
boolean subsumes(in nsIPrincipal other);
|
2005-07-22 23:05:42 +04:00
|
|
|
|
2014-02-14 06:57:34 +04:00
|
|
|
/**
|
2014-02-14 06:57:36 +04:00
|
|
|
* Same as the previous method, subsumes(), but takes document.domain into
|
|
|
|
* account.
|
2014-02-14 06:57:34 +04:00
|
|
|
*/
|
|
|
|
boolean subsumesConsideringDomain(in nsIPrincipal other);
|
|
|
|
|
2017-01-18 15:17:19 +03:00
|
|
|
/**
|
|
|
|
* Same as the subsumesConsideringDomain(), but ignores the first party
|
|
|
|
* domain in its originAttributes.
|
|
|
|
*/
|
|
|
|
boolean subsumesConsideringDomainIgnoringFPD(in nsIPrincipal other);
|
|
|
|
|
2013-05-04 01:47:09 +04:00
|
|
|
%{C++
|
2017-02-22 14:19:03 +03:00
|
|
|
DECL_FAST_INLINE_HELPER(Subsumes)
|
|
|
|
DECL_FAST_INLINE_HELPER(SubsumesConsideringDomain)
|
|
|
|
DECL_FAST_INLINE_HELPER(SubsumesConsideringDomainIgnoringFPD)
|
|
|
|
#undef DECL_FAST_INLINE_HELPER
|
2013-05-04 01:47:09 +04:00
|
|
|
%}
|
|
|
|
|
2008-02-27 06:45:29 +03:00
|
|
|
/**
|
|
|
|
* Checks whether this principal is allowed to load the network resource
|
|
|
|
* located at the given URI under the same-origin policy. This means that
|
2019-07-08 19:37:45 +03:00
|
|
|
* content principals are only allowed to load resources from the same
|
2008-02-27 06:45:29 +03:00
|
|
|
* domain, the system principal is allowed to load anything, and null
|
2014-09-30 12:09:36 +04:00
|
|
|
* principals can only load URIs where they are the principal. This is
|
|
|
|
* changed by the optional flag allowIfInheritsPrincipal (which defaults to
|
|
|
|
* false) which allows URIs that inherit their loader's principal.
|
2008-02-27 06:45:29 +03:00
|
|
|
*
|
|
|
|
* If the load is allowed this function does nothing. If the load is not
|
|
|
|
* allowed the function throws NS_ERROR_DOM_BAD_URI.
|
|
|
|
*
|
|
|
|
* NOTE: Other policies might override this, such as the Access-Control
|
|
|
|
* specification.
|
|
|
|
* NOTE: The 'domain' attribute has no effect on the behaviour of this
|
|
|
|
* function.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param uri The URI about to be loaded.
|
2012-08-20 22:34:33 +04:00
|
|
|
* @param allowIfInheritsPrincipal If true, the load is allowed if the
|
|
|
|
* loadee inherits the principal of the
|
|
|
|
* loader.
|
2008-02-27 06:45:29 +03:00
|
|
|
* @throws NS_ERROR_DOM_BAD_URI if the load is not allowed.
|
|
|
|
*/
|
2019-12-13 09:24:12 +03:00
|
|
|
void checkMayLoad(in nsIURI uri,
|
2012-08-20 22:34:33 +04:00
|
|
|
in boolean allowIfInheritsPrincipal);
|
2008-02-27 06:45:29 +03:00
|
|
|
|
2019-12-13 09:24:12 +03:00
|
|
|
/**
|
|
|
|
* Like checkMayLoad, but if returning an error will also report that error
|
|
|
|
* to the console, using the provided window id. The window id may be 0 to
|
|
|
|
* report to just the browser console, not web consoles.
|
|
|
|
*/
|
|
|
|
void checkMayLoadWithReporting(in nsIURI uri,
|
|
|
|
in boolean allowIfInheritsPrincipal,
|
|
|
|
in unsigned long long innerWindowID);
|
|
|
|
|
2019-10-02 18:10:40 +03:00
|
|
|
/**
|
2020-04-27 13:54:47 +03:00
|
|
|
* Checks if the provided URI is considered third-party to the
|
2019-10-02 18:10:40 +03:00
|
|
|
* URI of the principal.
|
|
|
|
* Returns true if the URI is third-party.
|
|
|
|
*
|
|
|
|
* @param uri - The URI to check
|
|
|
|
*/
|
|
|
|
boolean isThirdPartyURI(in nsIURI uri);
|
|
|
|
|
|
|
|
/**
|
2020-04-27 13:54:47 +03:00
|
|
|
* Checks if the provided principal is considered third-party to the
|
2019-10-02 18:10:40 +03:00
|
|
|
* URI of the Principal.
|
|
|
|
* Returns true if the principal is third-party.
|
|
|
|
*
|
|
|
|
* @param principal - The principal to check
|
|
|
|
*/
|
|
|
|
boolean isThirdPartyPrincipal(in nsIPrincipal principal);
|
|
|
|
|
2020-04-27 13:54:47 +03:00
|
|
|
/**
|
|
|
|
* Checks if the provided channel is considered third-party to the
|
|
|
|
* URI of the principal.
|
|
|
|
* Returns true if the channel is third-party.
|
|
|
|
* Returns false if the Principal is a System Principal
|
|
|
|
*
|
|
|
|
* @param channel - The Channel to check
|
|
|
|
*/
|
|
|
|
boolean isThirdPartyChannel(in nsIChannel channel);
|
|
|
|
|
2015-05-15 02:24:25 +03:00
|
|
|
/**
|
|
|
|
* A dictionary of the non-default origin attributes associated with this
|
|
|
|
* nsIPrincipal.
|
|
|
|
*
|
|
|
|
* Attributes are tokens that are taken into account when determining whether
|
|
|
|
* two principals are same-origin - if any attributes differ, the principals
|
|
|
|
* are cross-origin, even if the scheme, host, and port are the same.
|
|
|
|
* Attributes should also be considered for all security and bucketing decisions,
|
|
|
|
* even those which make non-standard comparisons (like cookies, which ignore
|
|
|
|
* scheme, or quotas, which ignore subdomains).
|
|
|
|
*
|
|
|
|
* If you're looking for an easy-to-use canonical stringification of the origin
|
|
|
|
* attributes, see |originSuffix| below.
|
|
|
|
*/
|
|
|
|
[implicit_jscontext]
|
|
|
|
readonly attribute jsval originAttributes;
|
|
|
|
|
2016-12-19 13:30:06 +03:00
|
|
|
[noscript, notxpcom, nostdcall, binaryname(OriginAttributesRef)]
|
2017-01-12 19:38:48 +03:00
|
|
|
const_OriginAttributes OriginAttributesRef();
|
2016-12-19 13:30:06 +03:00
|
|
|
|
2015-05-15 02:55:52 +03:00
|
|
|
/**
|
|
|
|
* A canonical representation of the origin for this principal. This
|
2019-07-08 19:37:45 +03:00
|
|
|
* consists of a base string (which, for content principals, is of the
|
2015-05-15 02:55:52 +03:00
|
|
|
* format scheme://host:port), concatenated with |originAttributes| (see
|
|
|
|
* below).
|
|
|
|
*
|
|
|
|
* We maintain the invariant that principalA.equals(principalB) if and only
|
|
|
|
* if principalA.origin == principalB.origin.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString origin;
|
|
|
|
|
2019-11-28 12:22:17 +03:00
|
|
|
/**
|
|
|
|
* Returns an ASCII compatible representation
|
|
|
|
* of the principals Origin
|
|
|
|
*/
|
2020-01-07 12:53:21 +03:00
|
|
|
[noscript] readonly attribute ACString asciiOrigin;
|
2019-11-28 12:22:17 +03:00
|
|
|
|
2020-02-10 18:10:52 +03:00
|
|
|
/**
|
|
|
|
* Returns the "host:port" portion of the
|
|
|
|
* Principals URI, if any.
|
|
|
|
*/
|
2020-05-18 16:50:14 +03:00
|
|
|
readonly attribute ACString hostPort;
|
2020-02-10 18:10:52 +03:00
|
|
|
|
2020-05-26 14:58:06 +03:00
|
|
|
/**
|
2020-02-17 16:57:41 +03:00
|
|
|
* Returns the "host:port" portion of the
|
|
|
|
* Principals URI, if any.
|
|
|
|
*/
|
2020-05-26 14:58:06 +03:00
|
|
|
readonly attribute ACString asciiHost;
|
2020-02-17 16:57:41 +03:00
|
|
|
|
2020-02-24 19:57:40 +03:00
|
|
|
/**
|
|
|
|
* Returns the "host" portion of the
|
|
|
|
* Principals URI, if any.
|
|
|
|
*/
|
2020-06-30 19:25:45 +03:00
|
|
|
readonly attribute ACString host;
|
2020-02-24 19:57:40 +03:00
|
|
|
|
2020-02-12 19:13:19 +03:00
|
|
|
/**
|
2020-04-20 13:01:54 +03:00
|
|
|
* Returns the prepath of the principals uri
|
|
|
|
* follows the format scheme:
|
|
|
|
* "scheme://username:password@hostname:portnumber/"
|
|
|
|
*/
|
2020-08-25 16:58:49 +03:00
|
|
|
readonly attribute ACString prepath;
|
2020-04-20 13:01:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the filePath of the principals uri. See nsIURI.
|
|
|
|
*/
|
2020-08-25 16:58:49 +03:00
|
|
|
readonly attribute ACString filePath;
|
2020-02-12 19:13:19 +03:00
|
|
|
|
2019-10-22 19:03:27 +03:00
|
|
|
/**
|
|
|
|
* Returns the ASCII Spec from the Principals URI.
|
|
|
|
* Might return the empty string, e.g. for the case of
|
|
|
|
* a SystemPrincipal or an EpxandedPrincipal.
|
|
|
|
*
|
|
|
|
* WARNING: DO NOT USE FOR SECURITY CHECKS.
|
|
|
|
* just for logging purposes!
|
|
|
|
*/
|
2020-06-30 19:25:45 +03:00
|
|
|
readonly attribute ACString asciiSpec;
|
2019-10-22 19:03:27 +03:00
|
|
|
|
2020-08-04 14:10:41 +03:00
|
|
|
/**
|
|
|
|
* Returns the Spec from the Principals URI.
|
|
|
|
* Might return the empty string, e.g. for the case of
|
|
|
|
* a SystemPrincipal or an EpxandedPrincipal.
|
|
|
|
*
|
|
|
|
* WARNING: Do not land new Code using, as this will be removed soon
|
|
|
|
*/
|
|
|
|
readonly attribute ACString spec;
|
|
|
|
|
2020-01-22 20:14:08 +03:00
|
|
|
/* Returns the Pre Path of the Principals URI with
|
|
|
|
* user:pass stripped for privacy and spoof prevention
|
|
|
|
*/
|
2020-02-24 20:04:45 +03:00
|
|
|
readonly attribute ACString exposablePrePath;
|
2020-01-22 20:14:08 +03:00
|
|
|
|
2020-04-15 00:48:38 +03:00
|
|
|
/* Returns the Spec of the Principals URI with
|
|
|
|
* user/pass/ref/query stripped for privacy and spoof prevention
|
|
|
|
*/
|
2020-06-02 16:50:12 +03:00
|
|
|
readonly attribute ACString exposableSpec;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the scheme of the principals URI
|
|
|
|
*/
|
|
|
|
readonly attribute ACString scheme;
|
2020-04-15 00:48:38 +03:00
|
|
|
|
2019-09-26 13:47:03 +03:00
|
|
|
/**
|
|
|
|
* Checks if the Principal's URI Scheme matches with the parameter
|
|
|
|
*
|
|
|
|
* @param scheme The scheme to be checked
|
|
|
|
*/
|
2021-03-09 02:36:40 +03:00
|
|
|
[infallible]
|
2019-09-26 13:47:03 +03:00
|
|
|
boolean schemeIs(in string scheme);
|
|
|
|
|
2019-11-07 16:42:37 +03:00
|
|
|
/*
|
2021-03-09 02:36:40 +03:00
|
|
|
* Checks if the Principal's URI is contained in the given Pref
|
|
|
|
* @param pref The pref to be checked
|
|
|
|
*/
|
|
|
|
[infallible]
|
|
|
|
boolean isURIInPrefList(in string pref);
|
2019-11-07 16:42:37 +03:00
|
|
|
|
2019-12-06 15:32:27 +03:00
|
|
|
/*
|
|
|
|
* Uses NS_Security Compare to determine if the
|
|
|
|
* other URI is same-origin as the uri of the Principal
|
|
|
|
*/
|
2020-02-24 20:04:45 +03:00
|
|
|
bool isSameOrigin(in nsIURI otherURI, in bool aIsPrivateWin);
|
2019-12-06 15:32:27 +03:00
|
|
|
|
2020-03-03 15:58:38 +03:00
|
|
|
/*
|
|
|
|
* Checks if the Principal is allowed to load the Provided file:// URI
|
|
|
|
* using NS_RelaxStrictFileOriginPolicy
|
|
|
|
*/
|
|
|
|
bool allowsRelaxStrictFileOriginPolicy(in nsIURI aURI);
|
|
|
|
|
2020-02-17 16:57:41 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generates a Cache-Key for the Cors-Preflight Cache
|
|
|
|
*/
|
2020-10-26 16:39:12 +03:00
|
|
|
[noscript]
|
|
|
|
ACString getPrefLightCacheKey(in nsIURI aURI ,in bool aWithCredentials,
|
|
|
|
in const_OriginAttributes aOriginAttributes);
|
2020-02-17 16:57:41 +03:00
|
|
|
|
2020-02-27 03:22:27 +03:00
|
|
|
|
2020-05-19 17:51:40 +03:00
|
|
|
/*
|
|
|
|
* Checks if the Principals URI has first party storage access
|
|
|
|
* when loaded inside the provided 3rd party resource window.
|
|
|
|
* See also: ContentBlocking::ShouldAllowAccessFor
|
|
|
|
*/
|
|
|
|
bool hasFirstpartyStorageAccess(in mozIDOMWindow aWindow, out uint32_t rejectedReason);
|
|
|
|
|
|
|
|
|
2020-02-27 03:22:27 +03:00
|
|
|
/*
|
|
|
|
* Returns a Key for the LocalStorage Manager, used to
|
|
|
|
* check the Principals Origin Storage usage.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString localStorageQuotaKey;
|
|
|
|
|
2019-12-05 19:04:53 +03:00
|
|
|
/**
|
|
|
|
* Implementation of
|
|
|
|
* https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
|
|
|
|
*
|
|
|
|
* The value returned by this method feeds into the the Secure Context
|
|
|
|
* algorithm that determins the value of Window.isSecureContext and
|
|
|
|
* WorkerGlobalScope.isSecureContext.
|
|
|
|
*
|
|
|
|
* This method returns false instead of throwing upon errors.
|
|
|
|
*/
|
2020-04-20 13:01:54 +03:00
|
|
|
[infallible]
|
|
|
|
readonly attribute boolean isOriginPotentiallyTrustworthy;
|
2019-12-05 19:04:53 +03:00
|
|
|
|
2019-10-17 16:54:41 +03:00
|
|
|
/**
|
|
|
|
* Returns the Flags of the Principals
|
|
|
|
* associated AboutModule, in case there is one.
|
|
|
|
*/
|
2020-02-24 20:04:45 +03:00
|
|
|
uint32_t getAboutModuleFlags();
|
2019-10-17 16:54:41 +03:00
|
|
|
|
2020-03-29 18:31:24 +03:00
|
|
|
/*
|
|
|
|
* Returns the Key to access the Principals
|
|
|
|
* Origin Local/Session Storage
|
|
|
|
*/
|
|
|
|
readonly attribute ACString storageOriginKey;
|
|
|
|
|
2020-03-05 16:42:13 +03:00
|
|
|
/**
|
|
|
|
* Creates and Returns a new ReferrerInfo with the
|
|
|
|
* Principals URI
|
|
|
|
*/
|
|
|
|
nsIReferrerInfo createReferrerInfo(in ReferrerPolicy aReferrerPolicy);
|
|
|
|
|
2015-05-15 02:55:52 +03:00
|
|
|
/**
|
|
|
|
* The base part of |origin| without the concatenation with |originSuffix|.
|
|
|
|
* This doesn't have the important invariants described above with |origin|,
|
|
|
|
* and as such should only be used for legacy situations.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString originNoSuffix;
|
|
|
|
|
2015-05-15 02:24:25 +03:00
|
|
|
/**
|
|
|
|
* A string of the form !key1=value1&key2=value2, where each pair represents
|
|
|
|
* an attribute with a non-default value. If all attributes have default
|
|
|
|
* values, this is the empty string.
|
|
|
|
*
|
|
|
|
* The value of .originSuffix is automatically serialized into .origin, so any
|
|
|
|
* consumers using that are automatically origin-attribute-aware. Consumers with
|
|
|
|
* special requirements must inspect and compare .originSuffix manually.
|
|
|
|
*/
|
|
|
|
readonly attribute AUTF8String originSuffix;
|
|
|
|
|
2018-09-05 06:22:16 +03:00
|
|
|
/**
|
|
|
|
* A canonical representation of the site-origin for this principal.
|
|
|
|
* This string has the same format as |origin| (see above). Two principals
|
|
|
|
* with differing |siteOrigin| values will never compare equal, even when
|
|
|
|
* considering domain mutations.
|
|
|
|
*
|
|
|
|
* For most principals, |siteOrigin| matches |origin| precisely. Only
|
|
|
|
* principals which allow mutating |domain|, such as ContentPrincipal,
|
|
|
|
* override the default implementation in BasePrincipal.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString siteOrigin;
|
|
|
|
|
2020-11-28 10:21:32 +03:00
|
|
|
/**
|
|
|
|
* The base part of |siteOrigin| without the concatenation with
|
|
|
|
* |originSuffix|.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString siteOriginNoSuffix;
|
|
|
|
|
2013-01-09 01:53:29 +04:00
|
|
|
/**
|
2019-07-08 19:37:45 +03:00
|
|
|
* The base domain of the principal URI to which this principal pertains
|
2013-01-09 01:53:29 +04:00
|
|
|
* (generally the document URI), handling null principals and
|
|
|
|
* non-hierarchical schemes correctly.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString baseDomain;
|
2013-01-26 21:56:23 +04:00
|
|
|
|
2016-04-24 06:56:56 +03:00
|
|
|
/**
|
|
|
|
* Gets the ID of the add-on this principal belongs to.
|
|
|
|
*/
|
|
|
|
readonly attribute AString addonId;
|
|
|
|
|
2017-09-05 21:04:43 +03:00
|
|
|
readonly attribute nsISupports addonPolicy;
|
|
|
|
|
2015-07-30 21:15:00 +03:00
|
|
|
/**
|
|
|
|
* Gets the id of the user context this principal is inside. If this
|
|
|
|
* principal is inside the default userContext, this returns
|
|
|
|
* nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute unsigned long userContextId;
|
|
|
|
|
2016-06-29 15:01:00 +03:00
|
|
|
/**
|
|
|
|
* Gets the id of the private browsing state of the context containing
|
|
|
|
* this principal. If the principal has a private browsing value of 0, it
|
|
|
|
* is not in private browsing.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute unsigned long privateBrowsingId;
|
|
|
|
|
2012-07-31 19:47:20 +04:00
|
|
|
/**
|
2016-02-05 04:42:44 +03:00
|
|
|
* Returns true iff the principal is inside an isolated mozbrowser element.
|
2016-10-15 04:46:26 +03:00
|
|
|
* <xul:browser> is not considered to be a mozbrowser element.
|
|
|
|
* <iframe mozbrowser noisolation> does not count as isolated since
|
|
|
|
* isolation is disabled. Isolation can only be disabled if the
|
|
|
|
* containing document is chrome.
|
2012-07-31 19:47:20 +04:00
|
|
|
*/
|
2016-02-05 04:42:44 +03:00
|
|
|
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
|
2012-10-24 21:50:25 +04:00
|
|
|
|
2012-10-23 20:31:19 +04:00
|
|
|
/**
|
2015-10-24 03:58:21 +03:00
|
|
|
* Returns true iff this is a null principal (corresponding to an
|
2012-10-23 20:31:19 +04:00
|
|
|
* unknown, hence assumed minimally privileged, security context).
|
|
|
|
*/
|
2012-11-10 22:32:36 +04:00
|
|
|
[infallible] readonly attribute boolean isNullPrincipal;
|
2015-03-13 23:15:09 +03:00
|
|
|
|
2015-10-24 03:58:21 +03:00
|
|
|
/**
|
2019-07-08 19:37:45 +03:00
|
|
|
* Returns true iff this principal corresponds to a principal origin.
|
2015-10-24 03:58:21 +03:00
|
|
|
*/
|
2019-07-08 19:37:45 +03:00
|
|
|
[infallible] readonly attribute boolean isContentPrincipal;
|
2015-10-24 03:58:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true iff this is an expanded principal.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute boolean isExpandedPrincipal;
|
|
|
|
|
|
|
|
/**
|
2019-01-03 23:55:38 +03:00
|
|
|
* Returns true iff this is the system principal. C++ callers should use
|
|
|
|
* IsSystemPrincipal() instead of this scriptable accessor.
|
2015-10-24 03:58:21 +03:00
|
|
|
*/
|
2019-01-03 23:55:38 +03:00
|
|
|
readonly attribute boolean isSystemPrincipal;
|
2018-07-14 05:26:15 +03:00
|
|
|
|
2019-01-03 23:08:55 +03:00
|
|
|
/**
|
|
|
|
* Faster and nicer version callable from C++. Callers must include
|
|
|
|
* BasePrincipal.h, where it's implemented.
|
|
|
|
*/
|
|
|
|
%{C++
|
|
|
|
inline bool IsSystemPrincipal() const;
|
|
|
|
%}
|
|
|
|
|
2018-07-14 05:26:15 +03:00
|
|
|
/**
|
|
|
|
* Returns true iff the principal is either an addon principal or
|
|
|
|
* an expanded principal, which contains at least one addon principal.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute boolean isAddonOrExpandedAddonPrincipal;
|
2019-09-24 10:56:40 +03:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
// MOZ_DBG support
|
|
|
|
friend std::ostream& operator<<(std::ostream& aOut, const nsIPrincipal& aPrincipal) {
|
|
|
|
nsIPrincipal* principal = const_cast<nsIPrincipal*>(&aPrincipal);
|
|
|
|
nsAutoCString origin;
|
|
|
|
mozilla::DebugOnly<nsresult> rv = principal->GetOrigin(origin);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
return aOut << "nsIPrincipal { " << origin << " }";
|
|
|
|
}
|
|
|
|
%}
|
2019-11-28 12:22:17 +03:00
|
|
|
/*
|
|
|
|
* Returns true if the URI is an Onion URI
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute boolean isOnion;
|
2020-02-27 02:15:43 +03:00
|
|
|
|
2020-03-09 16:28:03 +03:00
|
|
|
/*
|
|
|
|
* Returns true if the Domain Policy allows js execution
|
|
|
|
* for the Principals URI
|
|
|
|
*/
|
|
|
|
readonly attribute boolean isScriptAllowedByPolicy;
|
|
|
|
|
2020-03-26 16:18:40 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns true if the Principal can acess l10n
|
|
|
|
* features for the Provided DocumentURI
|
|
|
|
*/
|
|
|
|
boolean isL10nAllowed(in nsIURI aDocumentURI);
|
2020-04-20 12:43:22 +03:00
|
|
|
|
2020-04-20 12:53:40 +03:00
|
|
|
/**
|
|
|
|
* Returns a nsIPrincipal, with one less Subdomain Segment
|
|
|
|
* Returns `nullptr` if there are no more segments to remove.
|
|
|
|
*/
|
|
|
|
|
|
|
|
[infallible] readonly attribute nsIPrincipal nextSubDomainPrincipal;
|
|
|
|
|
2020-02-27 02:15:43 +03:00
|
|
|
/**
|
|
|
|
* Returns if the principal is for an IP address.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute boolean isIpAddress;
|
2020-08-24 19:28:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the principal is for a local IP address.
|
|
|
|
*/
|
|
|
|
[infallible] readonly attribute boolean isLocalIpAddress;
|
|
|
|
|
1999-07-24 07:58:23 +04:00
|
|
|
};
|
2012-06-11 03:44:50 +04:00
|
|
|
|
|
|
|
/**
|
2017-03-22 13:39:08 +03:00
|
|
|
* If SystemPrincipal is too risky to use, but we want a principal to access
|
2017-03-22 13:38:17 +03:00
|
|
|
* more than one origin, ExpandedPrincipals letting us define an array of
|
|
|
|
* principals it subsumes. So script with an ExpandedPrincipals will gain
|
2013-01-26 21:56:23 +04:00
|
|
|
* same origin access when at least one of its principals it contains gained
|
2017-03-22 13:38:17 +03:00
|
|
|
* sameorigin acccess. An ExpandedPrincipal will be subsumed by the system
|
|
|
|
* principal, and by another ExpandedPrincipal that has all its principals.
|
2012-06-11 03:44:50 +04:00
|
|
|
* It is added for jetpack content-scripts to let them interact with the
|
2013-01-26 21:56:23 +04:00
|
|
|
* content and a well defined set of other domains, without the risk of
|
2012-06-11 03:44:50 +04:00
|
|
|
* leaking out a system principal to the content. See: Bug 734891
|
|
|
|
*/
|
|
|
|
[uuid(f3e177Df-6a5e-489f-80a7-2dd1481471d8)]
|
|
|
|
interface nsIExpandedPrincipal : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* An array of principals that the expanded principal subsumes.
|
2017-11-03 05:56:27 +03:00
|
|
|
*
|
|
|
|
* When an expanded principal is used as a triggering principal for a
|
|
|
|
* request that inherits a security context, one of its constitutent
|
|
|
|
* principals is inherited rather than the expanded principal itself. The
|
2018-10-31 20:56:43 +03:00
|
|
|
* last principal in the allowlist is the default principal to inherit.
|
2017-11-03 05:56:27 +03:00
|
|
|
*
|
2013-01-26 21:56:23 +04:00
|
|
|
* Note: this list is not reference counted, it is shared, so
|
2012-06-11 03:44:50 +04:00
|
|
|
* should not be changed and should only be used ephemerally.
|
|
|
|
*/
|
2017-10-11 01:00:16 +03:00
|
|
|
[noscript, notxpcom, nostdcall]
|
2018-10-31 20:56:43 +03:00
|
|
|
PrincipalArray AllowList();
|
2019-05-22 02:14:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bug 1548468: Move CSP off ExpandedPrincipal.
|
|
|
|
*
|
|
|
|
* A Content Security Policy associated with this principal. Use this function
|
|
|
|
* to query the associated CSP with this principal.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIContentSecurityPolicy csp;
|
|
|
|
|
|
|
|
%{ C++
|
|
|
|
inline already_AddRefed<nsIContentSecurityPolicy> GetCsp()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> result;
|
|
|
|
mozilla::DebugOnly<nsresult> rv = GetCsp(getter_AddRefs(result));
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2012-10-24 21:50:25 +04:00
|
|
|
};
|