зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1017257 - Attach Loop CSP Policy r=sstamm
This commit is contained in:
Родитель
5ed12c768e
Коммит
f1a8c1f87f
|
@ -1616,6 +1616,7 @@ pref("loop.debug.loglevel", "Error");
|
|||
pref("loop.debug.dispatcher", false);
|
||||
pref("loop.debug.websocket", false);
|
||||
pref("loop.debug.sdk", false);
|
||||
pref("loop.CSP", "default-src 'self' about: file: chrome:; img-src 'self' data: http://www.gravatar.com/ about: file: chrome:; font-src 'none'; connect-src wss://*.tokbox.com https://*.opentok.com https://*.tokbox.com wss://*.mozilla.com wss://*.mozaws.net");
|
||||
pref("loop.oauth.google.redirect_uri", "urn:ietf:wg:oauth:2.0:oob:auto");
|
||||
pref("loop.oauth.google.scope", "https://www.google.com/m8/feeds");
|
||||
|
||||
|
|
|
@ -2752,6 +2752,33 @@ AppendCSPFromHeader(nsIContentSecurityPolicy* csp,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsLoopDocument(nsIChannel *aChannel)
|
||||
{
|
||||
nsCOMPtr<nsIURI> chanURI;
|
||||
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(chanURI));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
bool isAbout = false;
|
||||
bool isLoop = false;
|
||||
rv = chanURI->SchemeIs("about", &isAbout);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
if (isAbout) {
|
||||
nsCOMPtr<nsIURI> loopURI;
|
||||
rv = NS_NewURI(getter_AddRefs(loopURI), "about:loopconversation");
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
rv = chanURI->EqualsExceptRef(loopURI, &isLoop);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
if (!isLoop) {
|
||||
rv = NS_NewURI(getter_AddRefs(loopURI), "about:looppanel");
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
rv = chanURI->EqualsExceptRef(loopURI, &isLoop);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
}
|
||||
}
|
||||
return isLoop;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::InitCSP(nsIChannel* aChannel)
|
||||
{
|
||||
|
@ -2805,9 +2832,13 @@ nsDocument::InitCSP(nsIChannel* aChannel)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if this is part of the Loop/Hello service
|
||||
bool applyLoopCSP = IsLoopDocument(aChannel);
|
||||
|
||||
// If there's no CSP to apply, go ahead and return early
|
||||
if (!applyAppDefaultCSP &&
|
||||
!applyAppManifestCSP &&
|
||||
!applyLoopCSP &&
|
||||
cspHeaderValue.IsEmpty() &&
|
||||
cspROHeaderValue.IsEmpty()) {
|
||||
#ifdef PR_LOGGING
|
||||
|
@ -2880,6 +2911,17 @@ nsDocument::InitCSP(nsIChannel* aChannel)
|
|||
csp->AppendPolicy(appManifestCSP, false);
|
||||
}
|
||||
|
||||
// ----- if the doc is part of Loop, apply the loop CSP
|
||||
if (applyLoopCSP) {
|
||||
nsAdoptingString loopCSP;
|
||||
loopCSP = Preferences::GetString("loop.CSP");
|
||||
NS_ASSERTION(loopCSP, "Missing loop.CSP preference");
|
||||
// If the pref has been removed, we continue without setting a CSP
|
||||
if (loopCSP) {
|
||||
csp->AppendPolicy(loopCSP, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ----- if there's a full-strength CSP header, apply it.
|
||||
if (!cspHeaderValue.IsEmpty()) {
|
||||
rv = AppendCSPFromHeader(csp, cspHeaderValue, false);
|
||||
|
|
|
@ -1662,6 +1662,7 @@ private:
|
|||
void DoUnblockOnload();
|
||||
|
||||
nsresult CheckFrameOptions();
|
||||
bool IsLoopDocument(nsIChannel* aChannel);
|
||||
nsresult InitCSP(nsIChannel* aChannel);
|
||||
|
||||
void FlushCSPWebConsoleErrorQueue()
|
||||
|
|
|
@ -254,6 +254,7 @@ user_pref("loop.enabled", true);
|
|||
user_pref("loop.throttled", false);
|
||||
user_pref("loop.oauth.google.URL", "http://%(server)s/browser/browser/components/loop/test/mochitest/google_service.sjs?action=");
|
||||
user_pref("loop.oauth.google.getContactsURL", "http://%(server)s/browser/browser/components/loop/test/mochitest/google_service.sjs?action=contacts");
|
||||
user_pref("loop.CSP","default-src 'self' about: file: chrome: data: wss://* http://* https://*");
|
||||
|
||||
// Ensure UITour won't hit the network
|
||||
user_pref("browser.uitour.pinnedTabUrl", "http://%(server)s/uitour-dummy/pinnedTab");
|
||||
|
|
Загрузка…
Ссылка в новой задаче