diff --git a/install/data/defaults.json b/install/data/defaults.json index 6bf502abe1..b18c3dd9a7 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -146,6 +146,8 @@ "dailyDigestFreq": "off", "digestHour": 17, "passwordExpiryDays": 0, + "cross-origin-embedder-policy": 1, + "cross-origin-resource-policy": "same-origin", "hsts-maxage": 31536000, "hsts-subdomains": 0, "hsts-preload": 0, diff --git a/public/language/en-GB/admin/settings/advanced.json b/public/language/en-GB/admin/settings/advanced.json index ce0782be9e..ddf000be64 100644 --- a/public/language/en-GB/admin/settings/advanced.json +++ b/public/language/en-GB/admin/settings/advanced.json @@ -15,6 +15,9 @@ "headers.acac": "Access-Control-Allow-Credentials", "headers.acam": "Access-Control-Allow-Methods", "headers.acah": "Access-Control-Allow-Headers", + "headers.coep": "Cross-Origin-Embedder-Policy", + "headers.coep-help": "When enabled (default), will set the header to require-corp", + "headers.corp": "Cross-Origin-Resource-Policy", "hsts": "Strict Transport Security", "hsts.enabled": "Enabled HSTS (recommended)", "hsts.maxAge": "HSTS Max Age", diff --git a/src/views/admin/settings/advanced.tpl b/src/views/admin/settings/advanced.tpl index b64a631f74..6f997604e6 100644 --- a/src/views/admin/settings/advanced.tpl +++ b/src/views/admin/settings/advanced.tpl @@ -66,6 +66,22 @@
+
+ +
+

[[admin/settings/advanced:headers.coep-help]]

+
+ + +
+
diff --git a/src/webserver.js b/src/webserver.js index c5f4aefa86..a4364ea317 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -184,16 +184,21 @@ function setupExpressApp(app) { } function setupHelmet(app) { + /** + * The only reason why these middlewares are all explicitly spelled out is because + * helmet.contentSecurityPolicy() is too restrictive and breaks plugins. + * + * It should be implemented in the future... 🔜 + */ + if (meta.config['cross-origin-embedder-policy']) { + app.use(helmet.crossOriginEmbedderPolicy()); + } + app.use(helmet.crossOriginOpenerPolicy()); + app.use(helmet.crossOriginResourcePolicy({ policy: meta.config['cross-origin-resource-policy'] })); app.use(helmet.dnsPrefetchControl()); app.use(helmet.expectCt()); app.use(helmet.frameguard()); app.use(helmet.hidePoweredBy()); - app.use(helmet.ieNoOpen()); - app.use(helmet.noSniff()); - app.use(helmet.permittedCrossDomainPolicies()); - app.use(helmet.xssFilter()); - - app.use(helmet.referrerPolicy({ policy: 'strict-origin-when-cross-origin' })); if (meta.config['hsts-enabled']) { app.use(helmet.hsts({ maxAge: meta.config['hsts-maxage'], @@ -201,6 +206,12 @@ function setupHelmet(app) { preload: !!meta.config['hsts-preload'], })); } + app.use(helmet.ieNoOpen()); + app.use(helmet.noSniff()); + app.use(helmet.originAgentCluster()); + app.use(helmet.permittedCrossDomainPolicies()); + app.use(helmet.referrerPolicy({ policy: 'strict-origin-when-cross-origin' })); + app.use(helmet.xssFilter()); }