2014-07-10 10:56:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-02-13 22:36:47 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-10 10:56: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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_LoadInfo_h
|
|
|
|
#define mozilla_LoadInfo_h
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
#include "nsIContentPolicy.h"
|
2014-07-10 10:56:37 +04:00
|
|
|
#include "nsILoadInfo.h"
|
2014-07-17 00:16:12 +04:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
2014-11-05 03:34:00 +03:00
|
|
|
#include "nsIURI.h"
|
2015-07-20 05:11:03 +03:00
|
|
|
#include "nsTArray.h"
|
2014-07-17 00:16:12 +04:00
|
|
|
|
2015-10-22 00:47:00 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
class nsINode;
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowOuter;
|
2014-07-10 10:56:37 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-06-27 20:13:41 +03:00
|
|
|
namespace dom {
|
|
|
|
class XMLHttpRequestMainThread;
|
|
|
|
}
|
|
|
|
|
2015-01-08 02:51:20 +03:00
|
|
|
namespace net {
|
2015-07-14 08:43:13 +03:00
|
|
|
class OptionalLoadInfoArgs;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
2015-06-19 01:37:20 +03:00
|
|
|
|
|
|
|
namespace ipc {
|
|
|
|
// we have to forward declare that function so we can use it as a friend.
|
|
|
|
nsresult
|
2015-07-14 08:43:13 +03:00
|
|
|
LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
2015-06-19 01:37:20 +03:00
|
|
|
nsILoadInfo** outLoadInfo);
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace ipc
|
2015-01-08 02:51:20 +03:00
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
namespace net {
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
/**
|
|
|
|
* Class that provides an nsILoadInfo implementation.
|
2015-04-02 21:35:40 +03:00
|
|
|
*
|
|
|
|
* Note that there is no reason why this class should be MOZ_EXPORT, but
|
|
|
|
* Thunderbird relies on some insane hacks which require this, so we'll leave it
|
|
|
|
* as is for now, but hopefully we'll be able to remove the MOZ_EXPORT keyword
|
|
|
|
* from this class at some point. See bug 1149127 for the discussion.
|
2014-07-10 10:56:37 +04:00
|
|
|
*/
|
2015-04-02 21:35:40 +03:00
|
|
|
class MOZ_EXPORT LoadInfo final : public nsILoadInfo
|
2014-07-10 10:56:37 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSILOADINFO
|
|
|
|
|
2014-11-14 19:55:59 +03:00
|
|
|
// aLoadingPrincipal MUST NOT BE NULL.
|
|
|
|
LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2014-07-17 00:16:12 +04:00
|
|
|
nsINode* aLoadingContext,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
2015-08-19 20:43:30 +03:00
|
|
|
nsContentPolicyType aContentPolicyType);
|
2014-07-10 10:56:37 +04:00
|
|
|
|
2016-04-14 02:30:16 +03:00
|
|
|
// Constructor used for TYPE_DOCUMENT loads which have no reasonable
|
|
|
|
// loadingNode or loadingPrincipal
|
2016-03-04 19:54:07 +03:00
|
|
|
LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags);
|
|
|
|
|
2015-11-01 01:20:48 +03:00
|
|
|
// create an exact copy of the loadinfo
|
2015-09-24 23:42:02 +03:00
|
|
|
already_AddRefed<nsILoadInfo> Clone() const;
|
2016-06-22 18:15:06 +03:00
|
|
|
// hands off!!! don't use CloneWithNewSecFlags unless you know
|
|
|
|
// exactly what you are doing - it should only be used within
|
|
|
|
// nsBaseChannel::Redirect()
|
|
|
|
already_AddRefed<nsILoadInfo>
|
|
|
|
CloneWithNewSecFlags(nsSecurityFlags aSecurityFlags) const;
|
2015-11-01 01:20:48 +03:00
|
|
|
// creates a copy of the loadinfo which is appropriate to use for a
|
|
|
|
// separate request. I.e. not for a redirect or an inner channel, but
|
|
|
|
// when a separate request is made with the same security properties.
|
|
|
|
already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
|
2015-09-24 23:42:02 +03:00
|
|
|
|
2015-12-07 02:33:14 +03:00
|
|
|
void SetIsPreflight();
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
private:
|
2015-01-08 02:51:20 +03:00
|
|
|
// private constructor that is only allowed to be called from within
|
|
|
|
// HttpChannelParent and FTPChannelParent declared as friends undeneath.
|
|
|
|
// In e10s we can not serialize nsINode, hence we store the innerWindowID.
|
2015-07-20 05:11:03 +03:00
|
|
|
// Please note that aRedirectChain uses swapElements.
|
2015-01-08 02:51:20 +03:00
|
|
|
LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2016-09-20 09:35:45 +03:00
|
|
|
nsIPrincipal* aPrincipalToInherit,
|
2015-01-08 02:51:20 +03:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-12-07 02:33:15 +03:00
|
|
|
LoadTainting aTainting,
|
2015-07-10 23:57:55 +03:00
|
|
|
bool aUpgradeInsecureRequests,
|
2016-03-14 13:56:52 +03:00
|
|
|
bool aVerifySignedContent,
|
2016-03-16 06:13:26 +03:00
|
|
|
bool aEnforceSRI,
|
2016-07-18 09:35:13 +03:00
|
|
|
bool aForceInheritPrincipalDropped,
|
2015-05-08 22:52:49 +03:00
|
|
|
uint64_t aInnerWindowID,
|
|
|
|
uint64_t aOuterWindowID,
|
2015-07-20 05:11:03 +03:00
|
|
|
uint64_t aParentOuterWindowID,
|
2016-06-27 03:42:00 +03:00
|
|
|
uint64_t aFrameOuterWindowID,
|
2015-07-20 05:11:57 +03:00
|
|
|
bool aEnforceSecurity,
|
|
|
|
bool aInitialSecurityCheckDone,
|
2015-12-01 00:25:29 +03:00
|
|
|
bool aIsThirdPartyRequest,
|
2015-11-03 04:50:54 +03:00
|
|
|
const NeckoOriginAttributes& aOriginAttributes,
|
2015-11-01 01:18:59 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
|
2015-12-07 02:33:14 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain,
|
|
|
|
const nsTArray<nsCString>& aUnsafeHeaders,
|
|
|
|
bool aForcePreflight,
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
bool aIsPreflight,
|
|
|
|
bool aForceHSTSPriming,
|
|
|
|
bool aMixedContentWouldBlock);
|
2015-09-24 23:42:02 +03:00
|
|
|
LoadInfo(const LoadInfo& rhs);
|
2015-01-08 02:51:20 +03:00
|
|
|
|
2015-06-19 01:37:20 +03:00
|
|
|
friend nsresult
|
2015-07-14 08:43:13 +03:00
|
|
|
mozilla::ipc::LoadInfoArgsToLoadInfo(
|
|
|
|
const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
|
|
|
nsILoadInfo** outLoadInfo);
|
2015-01-08 02:51:20 +03:00
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
~LoadInfo();
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void ComputeIsThirdPartyContext(nsPIDOMWindowOuter* aOuterWindow);
|
2015-12-01 00:25:29 +03:00
|
|
|
|
2015-10-19 21:14:54 +03:00
|
|
|
// This function is the *only* function which can change the securityflags
|
|
|
|
// of a loadinfo. It only exists because of the XHR code. Don't call it
|
|
|
|
// from anywhere else!
|
2015-12-07 02:33:15 +03:00
|
|
|
void SetIncludeCookiesSecFlag();
|
2016-06-27 20:13:41 +03:00
|
|
|
friend class mozilla::dom::XMLHttpRequestMainThread;
|
2015-10-19 21:14:54 +03:00
|
|
|
|
2015-11-01 01:20:48 +03:00
|
|
|
// if you add a member, please also update the copy constructor
|
2015-07-20 05:11:57 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
|
|
|
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
2016-09-20 09:35:45 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
|
2015-07-20 05:11:57 +03:00
|
|
|
nsWeakPtr mLoadingContext;
|
|
|
|
nsSecurityFlags mSecurityFlags;
|
2015-10-19 21:14:54 +03:00
|
|
|
nsContentPolicyType mInternalContentPolicyType;
|
2015-10-22 21:07:32 +03:00
|
|
|
LoadTainting mTainting;
|
2015-07-20 05:11:57 +03:00
|
|
|
bool mUpgradeInsecureRequests;
|
2016-03-14 13:56:52 +03:00
|
|
|
bool mVerifySignedContent;
|
2016-03-16 06:13:26 +03:00
|
|
|
bool mEnforceSRI;
|
2016-07-18 09:35:13 +03:00
|
|
|
bool mForceInheritPrincipalDropped;
|
2015-07-20 05:11:57 +03:00
|
|
|
uint64_t mInnerWindowID;
|
|
|
|
uint64_t mOuterWindowID;
|
|
|
|
uint64_t mParentOuterWindowID;
|
2016-06-27 03:42:00 +03:00
|
|
|
uint64_t mFrameOuterWindowID;
|
2015-07-20 05:11:57 +03:00
|
|
|
bool mEnforceSecurity;
|
|
|
|
bool mInitialSecurityCheckDone;
|
2015-12-01 00:25:29 +03:00
|
|
|
bool mIsThirdPartyContext;
|
2015-11-03 04:50:54 +03:00
|
|
|
NeckoOriginAttributes mOriginAttributes;
|
2015-11-01 01:18:59 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChainIncludingInternalRedirects;
|
2015-07-20 05:11:03 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain;
|
2015-12-07 02:33:14 +03:00
|
|
|
nsTArray<nsCString> mCorsUnsafeHeaders;
|
|
|
|
bool mForcePreflight;
|
|
|
|
bool mIsPreflight;
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
|
|
|
|
bool mForceHSTSPriming : 1;
|
|
|
|
bool mMixedContentWouldBlock : 1;
|
2014-07-10 10:56:37 +04:00
|
|
|
};
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
} // namespace net
|
2014-07-10 10:56:37 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_LoadInfo_h
|
|
|
|
|