File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ There are some config settings you need to change in the files below.
207207| ` HMD_HSTS_MAX_AGE ` | ` 31536000 ` | max duration in seconds to tell clients to keep HSTS status (default is a year) |
208208| ` HMD_HSTS_PRELOAD ` | ` true ` | whether to allow preloading of the site's HSTS status (e.g. into browsers) |
209209| ` HMD_CSP_ENABLE ` | ` true ` | whether to enable Content Security Policy (directives cannot be configured with environment variables) |
210+ | ` HMD_CSP_REPORTURI ` | ` https://<someid>.report-uri.com/r/d/csp/enforce ` | Allows to add a URL for CSP reports in case of violations |
210211
211212## Application settings ` config.json `
212213
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ module.exports = {
1818 directives : {
1919 } ,
2020 addDefaults : true ,
21- upgradeInsecureRequests : 'auto'
21+ upgradeInsecureRequests : 'auto' ,
22+ reportURI : undefined
2223 } ,
2324 protocolusessl : false ,
2425 usecdn : true ,
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ module.exports = {
1515 preload : toBooleanConfig ( process . env . HMD_HSTS_PRELOAD )
1616 } ,
1717 csp : {
18- enable : toBooleanConfig ( process . env . HMD_CSP_ENABLE )
18+ enable : toBooleanConfig ( process . env . HMD_CSP_ENABLE ) ,
19+ reportURI : process . env . HMD_CSP_REPORTURI
1920 } ,
2021 protocolusessl : toBooleanConfig ( process . env . HMD_PROTOCOL_USESSL ) ,
2122 alloworigin : toArrayConfig ( process . env . HMD_ALLOW_ORIGIN ) ,
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ CspStrategy.computeDirectives = function () {
3030 addInlineScriptExceptions ( directives )
3131 }
3232 addUpgradeUnsafeRequestsOptionTo ( directives )
33+ addReportURI ( directives )
3334 return directives
3435}
3536
@@ -72,6 +73,12 @@ function addUpgradeUnsafeRequestsOptionTo (directives) {
7273 }
7374}
7475
76+ function addReportURI ( directives ) {
77+ if ( config . csp . reportURI ) {
78+ directives . reportUri = config . csp . reportURI
79+ }
80+ }
81+
7582CspStrategy . addNonceToLocals = function ( req , res , next ) {
7683 res . locals . nonce = uuid . v4 ( )
7784 next ( )
You can’t perform that action at this time.
0 commit comments