CSP: Upgrade insecure requests if possible
Config option; default is to only upgrade if usessl
This commit is contained in:
parent
ba183ce654
commit
5d2d3ec875
2 changed files with 8 additions and 2 deletions
5
app.js
5
app.js
|
@ -126,6 +126,11 @@ if (config.csp.enable) {
|
||||||
directives[propertyName] = directive;
|
directives[propertyName] = directive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(config.csp.upgradeInsecureRequests === 'auto') {
|
||||||
|
directives.upgradeInsecureRequests = config.usessl === 'true'
|
||||||
|
} else {
|
||||||
|
directives.upgradeInsecureRequests = config.csp.upgradeInsecureRequests === 'true'
|
||||||
|
}
|
||||||
app.use(helmet.contentSecurityPolicy({
|
app.use(helmet.contentSecurityPolicy({
|
||||||
directives: directives
|
directives: directives
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -20,8 +20,9 @@ module.exports = {
|
||||||
defaultSrc: ["'self'"],
|
defaultSrc: ["'self'"],
|
||||||
scriptSrc: ["'self'"],
|
scriptSrc: ["'self'"],
|
||||||
styleSrc: ["'self'", "'unsafe-inline'"],
|
styleSrc: ["'self'", "'unsafe-inline'"],
|
||||||
fontSrc: ["'self'"]
|
fontSrc: ["'self'"],
|
||||||
}
|
},
|
||||||
|
upgradeInsecureRequests: 'auto'
|
||||||
},
|
},
|
||||||
protocolusessl: false,
|
protocolusessl: false,
|
||||||
usecdn: true,
|
usecdn: true,
|
||||||
|
|
Loading…
Reference in a new issue