CSP: Upgrade insecure requests if possible

Config option; default is to only upgrade if usessl
This commit is contained in:
Literallie 2017-10-18 17:45:57 +02:00
parent ba183ce654
commit 5d2d3ec875
No known key found for this signature in database
GPG Key ID: 7BE463C902ED152C
2 changed files with 8 additions and 2 deletions

5
app.js
View File

@ -126,6 +126,11 @@ if (config.csp.enable) {
directives[propertyName] = directive;
}
}
if(config.csp.upgradeInsecureRequests === 'auto') {
directives.upgradeInsecureRequests = config.usessl === 'true'
} else {
directives.upgradeInsecureRequests = config.csp.upgradeInsecureRequests === 'true'
}
app.use(helmet.contentSecurityPolicy({
directives: directives
}))

View File

@ -20,8 +20,9 @@ module.exports = {
defaultSrc: ["'self'"],
scriptSrc: ["'self'"],
styleSrc: ["'self'", "'unsafe-inline'"],
fontSrc: ["'self'"]
}
fontSrc: ["'self'"],
},
upgradeInsecureRequests: 'auto'
},
protocolusessl: false,
usecdn: true,