|
| 1 | +const isProduction = process.env.NODE_ENV === 'production'; |
| 2 | + |
| 3 | +let localhostPart = ''; |
| 4 | +if (!isProduction) { |
| 5 | + localhostPart = 'localhost:* '; |
| 6 | +} |
| 7 | +const connectSrcHosts = `'self' ${localhostPart}d3qlcaacmmrges.cloudfront.net px.ads.linkedin.com`; |
| 8 | + |
| 9 | +/** |
| 10 | + * Extends @apostrophecms/security-headers for reCAPTCHA, GTM, GA, Hotjar, |
| 11 | + * Facebook Pixel, and LinkedIn Insight. |
| 12 | + */ |
| 13 | +module.exports = { |
| 14 | + improve: '@apostrophecms/security-headers', |
| 15 | + options: { |
| 16 | + policies: { |
| 17 | + recaptcha: { |
| 18 | + 'script-src': '*.google.com *.gstatic.com', |
| 19 | + 'frame-src': '*.google.com *.recaptcha.net', |
| 20 | + }, |
| 21 | + inlineFonts: { |
| 22 | + 'font-src': 'data:', |
| 23 | + }, |
| 24 | + inlineScripts: { |
| 25 | + /* eslint-disable no-secrets/no-secrets -- CSP script hashes, not secrets */ |
| 26 | + 'script-src': |
| 27 | + "'sha256-oTA8qLsJHk9g+M1YNjqx2sHGYh6catTGwk9lmCk8hhs=' " + |
| 28 | + "'sha256-ZC4Ihfl+1sv3E25DQh090ITQKwffxiocyA9C1vaePKU=' " + |
| 29 | + "'sha256-Q/LPXhHka5/egcP/jMtr5hz7Sxemm+1q7K+bOgaJiMo=' " + |
| 30 | + "'sha256-3ZRDhT/4WJSTcMHjSSKp1/doi40daSfiQU6ZD395+DA=' " + |
| 31 | + "'sha256-huW3ylgdSqVTZdqsJoCPMlhbzwwaT0HRomNhtq49Beo=' " + |
| 32 | + "'sha256-zoD9yhjUIP539kmB7swNElD1S9L+cey6RvNjUnEcTU4='", |
| 33 | + /* eslint-enable no-secrets/no-secrets */ |
| 34 | + }, |
| 35 | + linkedin: { |
| 36 | + 'script-src': 'snap.licdn.com', |
| 37 | + 'connect-src': connectSrcHosts, |
| 38 | + 'img-src': 'px.ads.linkedin.com', |
| 39 | + }, |
| 40 | + googleAnalytics: { |
| 41 | + 'connect-src': '*.google-analytics.com *.analytics.google.com', |
| 42 | + }, |
| 43 | + hotjar: { |
| 44 | + 'script-src': '*.hotjar.com *.hotjar.io', |
| 45 | + 'connect-src': |
| 46 | + 'https://*.hotjar.com https://*.hotjar.io wss://*.hotjar.com', |
| 47 | + 'img-src': |
| 48 | + 'https://static.hotjar.com https://script.hotjar.com ' + |
| 49 | + 'https://survey-images.hotjar.com', |
| 50 | + 'font-src': 'https://script.hotjar.com', |
| 51 | + 'style-src': 'https://static.hotjar.com https://script.hotjar.com', |
| 52 | + }, |
| 53 | + facebook: { |
| 54 | + 'script-src': 'connect.facebook.net', |
| 55 | + 'connect-src': 'https://www.facebook.com', |
| 56 | + 'img-src': 'https://www.facebook.com', |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, |
| 60 | +}; |
0 commit comments