Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions Framework/Backend/http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ class HttpServer {
* @param {number} config.port secure port number
* @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 {boolean} config.allowIframeCsp allow blob: URLs in img-src (image previews/downloads)
* @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
4 changes: 4 additions & 0 deletions Framework/docs/guide/http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Where:
* [`TLS_CERT`] - certificate filepath, TLS must be enabled
* [`AUTO_LISTEN`] - flag that enables/disables automatic listening (default: `true`)
* [`LIMIT`] - controls the maximum request body size. Defaults to '100kb'.
* [`iframeCsp`] - list of URLs allowed in the `frame-src` CSP directive (default: `[]`)
* [`allow`] - adds `'unsafe-eval'` to `script-src` (default: `false`)
* [`allowIframeCsp`] - adds `blob:` to `img-src` so blob-based images can be previewed/downloaded; despite the name, unrelated to iframes (default: `false`)
* [`extraConnectSrc`] - sources appended to the default `connect-src` CSP directive (default: `[]`)
* [`JWT_CONF`] - JWT module config, see [JWT module](json-tokens.md)
* [`OPENID_CONF`] - OpenID config, see [OpenID Connect module](openid.md)

Expand Down
Loading