-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add static file configuration to use the govuk npm directory and upda…
…te related tests files
- Loading branch information
1 parent
3ed1c5c
commit 6c522e0
Showing
9 changed files
with
54 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
import express from 'express'; | ||
import helmet from 'helmet'; | ||
import helmet, { HelmetOptions } from 'helmet'; | ||
|
||
import * as config from '../config'; | ||
|
||
export const configureHelmet = (app: express.Application) => { | ||
app.use(helmet({ | ||
referrerPolicy: { | ||
policy: 'strict-origin-when-cross-origin' | ||
export const HELMET_OPTIONS: HelmetOptions = { | ||
referrerPolicy: { | ||
policy: 'strict-origin-when-cross-origin' | ||
}, | ||
contentSecurityPolicy: { | ||
useDefaults: true, | ||
directives: { | ||
defaultSrc: ["'self'"], | ||
fontSrc: ["'self'", config.CDN_HOST], | ||
styleSrc: [ | ||
"'self'", | ||
"'unsafe-hashes'", | ||
"'sha256-6FWIojjtZwiNizws7ImlHjGH3DA5yMh5x4c+/4UVpXk='", | ||
config.CDN_HOST | ||
], | ||
scriptSrc: [ | ||
"'self'", | ||
"'sha256-pOe+O2hOZnTvxPXzgAfiocCoHgEZxBBgg+a66TylmHw='", | ||
"'sha256-GUQ5ad8JK5KmEWmROf3LZd9ge94daqNvd8xy9YS1iDw='", | ||
"'sha256-rDMP7u4Lf+tIufrYmUZIhcf2T3WBD4Pweu0EXe+qaLA='", | ||
"'sha256-wJphCpPdstup3Ojta3HnXJ3EOilATTTWg5oi4S9oi4s='", | ||
config.CDN_HOST | ||
], | ||
imgSrc: ["'self'", 'data:', config.CDN_HOST], | ||
connectSrc: ["'self'"], | ||
formAction: ["'self'"], | ||
objectSrc: ["'none'"] | ||
}, | ||
contentSecurityPolicy: { | ||
useDefaults: true, | ||
directives: { | ||
defaultSrc: ["'self'"], | ||
fontSrc: ["'self'", config.CDN_HOST], | ||
styleSrc: ["'self'", "'unsafe-hashes'", "'sha256-6FWIojjtZwiNizws7ImlHjGH3DA5yMh5x4c+/4UVpXk='", config.CDN_HOST], | ||
scriptSrc: [ | ||
"'self'", | ||
"'sha256-GUQ5ad8JK5KmEWmROf3LZd9ge94daqNvd8xy9YS1iDw='", | ||
"'sha256-rDMP7u4Lf+tIufrYmUZIhcf2T3WBD4Pweu0EXe+qaLA='", | ||
config.CDN_HOST | ||
], | ||
imgSrc: ["'self'", 'data:', config.CDN_HOST], | ||
connectSrc: ["'self'"], | ||
formAction: ["'self'"], | ||
objectSrc: ["'none'"] | ||
}, | ||
reportOnly: false | ||
} | ||
})); | ||
reportOnly: false | ||
} | ||
}; | ||
|
||
export const configureHelmet = (app: express.Application) => { | ||
app.use(helmet(HELMET_OPTIONS)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters