Skip to content

Commit

Permalink
fix(csp): change helmet config for 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Aug 6, 2020
1 parent 6de41ff commit 5953f95
Showing 1 changed file with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,31 @@ if (sentryDns) {
}

const app = express()
app.use(helmet())
app.use(
helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
styleSrc: [
"'self'",
"'unsafe-inline'",
'fonts.googleapis.com',
'cdn.jsdelivr.net/npm/sgds-govtech@1.3.13/',
],
fontSrc: [
"'self'",
'fonts.gstatic.com',
'cdn.jsdelivr.net/npm/sgds-govtech@1.3.13/',
],
imgSrc: [
"'self'",
'data:',
'www.google-analytics.com',
'www.googletagmanager.com',
],
scriptSrc: [
"'self'",
'www.google-analytics.com',
'www.googletagmanager.com',
],
connectSrc,
frameAncestors: ["'self'"],
...(cspReportUri ? { reportUri: cspReportUri } : {}),
upgradeInsecureRequests: true,
helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
styleSrc: ["'self'", "'unsafe-inline'", 'fonts.googleapis.com'],
fontSrc: ["'self'", 'fonts.gstatic.com'],
imgSrc: [
"'self'",
'data:',
'www.google-analytics.com',
'www.googletagmanager.com',
],
scriptSrc: [
"'self'",
'www.google-analytics.com',
'www.googletagmanager.com',
],
connectSrc,
frameAncestors: ["'self'"],
...(cspReportUri ? { reportUri: cspReportUri } : {}),
upgradeInsecureRequests: [],
},
reportOnly: cspOnlyReportViolations,
},
reportOnly: cspOnlyReportViolations,
}),
)

Expand Down

0 comments on commit 5953f95

Please sign in to comment.