Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Framework/Backend/http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ class HttpServer {
* @param {list} config.iframeCsp list of URLs for frame-src CSP
* @param {boolean} config.allow allow unsafe-eval in CSP
* @param {boolean} config.allowIframeCsp allow iframe embedding from given URLs
* @param {list} [config.extraConnectSrc] sources appended to the default connect-src CSP
*/
configureHelmet({ hostname, port, iframeCsp = [], allow = false, allowIframeCsp = false }) {
configureHelmet({ hostname, port, iframeCsp = [], allow = false, allowIframeCsp = false, extraConnectSrc = [] }) {
// Sets "X-Frame-Options: DENY" (doesn't allow to be in any iframe)
this.app.use(helmet.frameguard({ action: 'deny' }));
// Sets "Strict-Transport-Security: max-age=5184000 (60 days) (stick to HTTPS)
Expand All @@ -171,7 +172,8 @@ class HttpServer {
...(allowIframeCsp && { imgSrc: ["'self'", "data:", "blob:"] }),
scriptSrc: ["'self'", ...(allow ? ["'unsafe-eval'"] : [])],
styleSrc: ["'self'", "'unsafe-inline'"],
connectSrc: ["'self'", 'http://' + hostname + ':' + port, 'https://' + hostname, 'wss://' + hostname, 'ws://' + hostname + ':' + port],
connectSrc: ["'self'", 'http://' + hostname + ':' + port, 'https://' + hostname, 'wss://' + hostname, 'ws://' + hostname + ':' + port,
...extraConnectSrc],
upgradeInsecureRequests: null,
frameSrc: iframeCsp
/* eslint-enable */
Expand Down
Loading