Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2933, allow for EXTRA_CONTENT_ORIGIN (#2950)
Browse files Browse the repository at this point in the history
This adds a new configuration, EXTRA_CONTENT_ORIGIN, which is added to the CSP
This is intended just for migrating the pageshot.net content origin
  • Loading branch information
ianb authored and jaredhirsch committed Jun 1, 2017
1 parent f94bdfd commit 1b746f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ var conf = convict({
env: "CONTENT_ORIGIN",
arg: "contentOrigin"
},
extraContentOrigin: {
doc: "If you have a second origin available for migration purposes",
format: String,
default: "",
env: "EXTRA_CONTENT_ORIGIN",
arg: "extraContentOrigin"
},
expectProtocol: {
doc: "Treat all incoming requests as using this protocol, instead of defaulting to http: or detecting from X-Forwarded-Proto",
format: String,
Expand Down
3 changes: 2 additions & 1 deletion server/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ app.use((req, res, next) => {
} else {
dsn = "";
}
let extraContentOrigin = config.extraContentOrigin || "";
req.cspNonce = uuid;
res.header(
"Content-Security-Policy",
`default-src 'self'; img-src 'self' www.google-analytics.com ${CONTENT_NAME} data:; script-src 'self' www.google-analytics.com 'nonce-${uuid}'; style-src 'self' 'unsafe-inline' https://code.cdn.mozilla.net; connect-src 'self' www.google-analytics.com ${dsn}; font-src https://code.cdn.mozilla.net; frame-ancestors 'none'; object-src 'none';`);
`default-src 'self'; img-src 'self' www.google-analytics.com ${CONTENT_NAME}${extraContentOrigin && ' ' + extraContentOrigin} data:; script-src 'self' www.google-analytics.com 'nonce-${uuid}'; style-src 'self' 'unsafe-inline' https://code.cdn.mozilla.net; connect-src 'self' www.google-analytics.com ${dsn}; font-src https://code.cdn.mozilla.net; frame-ancestors 'none'; object-src 'none';`);
res.header("X-Frame-Options", "DENY");
res.header("X-Content-Type-Options", "nosniff");
addHSTS(req, res);
Expand Down

0 comments on commit 1b746f9

Please sign in to comment.