Added Strict-Transport-Security HTTP header by default.

Ylian Saint-Hilaire committed Jun 25, 2021 at 13:11 UTC 657c4c2939cad5f76099168364270d3b33c4b317
2 files changed +2
meshcentral-config-schema.json
+1
@@ -89,6 +89,7 @@
89 "ignoreAgentHashCheck": { "type": [ "boolean", "string" ], "default": false, "description": "When true, the agent no longer checked the TLS certificate of the server. This should be used for debugging only. You can also set this to a comma seperated list of IP addresses to ignore, for example: \"192.168.2.100,192.168.1.0/24\"." },
90 "exactPorts": { "type": "boolean", "default": false },
91 "allowLoginToken": { "type": "boolean", "default": false },
92 + "StrictTransportSecurity": { "type": ["boolean", "string"], "default": true, "description": "Controls the Strict-Transport-Security header, default is 1 year. Set to false to remove, or string to set a custom value." },
93 "allowFraming": { "type": "boolean", "default": false, "description": "When enabled, the MeshCentral web site can be embedded within another website's iframe." },
94 "cookieIpCheck": { "type": "boolean" },
95 "cookieEncoding": { "type": "string", "enum": [ "hex", "base64" ], "default": "base64", "description": "Encoding format of cookies in the HTTP headers, this is typically Base64 but some reverse proxies will require HEX." },
webserver.js
+1
@@ -5459,6 +5459,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5459 'Content-Security-Policy': "default-src 'none'; font-src 'self'; script-src 'self' 'unsafe-inline'" + extraScriptSrc + "; connect-src 'self'" + geourl + selfurl + "; img-src 'self' blob: data:" + geourl + " data:; style-src 'self' 'unsafe-inline'; frame-src 'self' mcrouter:; media-src 'self'; form-action 'self'"
5460 };
5461 if ((parent.config.settings.allowframing !== true) && (typeof parent.config.settings.allowframing !== 'string')) { headers['X-Frame-Options'] = 'sameorigin'; }
5462 + if (parent.config.settings.stricttransportsecurity !== false) { if (typeof parent.config.settings.stricttransportsecurity == 'string') { headers['Strict-Transport-Security'] = parent.config.settings.stricttransportsecurity; } else { headers['Strict-Transport-Security'] = 'max-age=63072000'; } }
5463 res.set(headers);
5464 }
5465