cloudcms-server 0.9.248 → 0.9.249

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "0.9.248",
9
+ "version": "0.9.249",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
@@ -39,6 +39,7 @@
39
39
  "gitana": "^1.0.315",
40
40
  "handlebars": "^4.4.2",
41
41
  "hbs": "^4.0.5",
42
+ "helmet": "^4.6.0",
42
43
  "http-proxy": "^1.18.1",
43
44
  "json5": "^1.0.1",
44
45
  "jsonwebtoken": "^8.5.1",
package/server/index.js CHANGED
@@ -37,6 +37,8 @@ var duster = require("../duster/index");
37
37
 
38
38
  var coreHelpers = require("../duster/helpers/core/index");
39
39
 
40
+ var helmet = require("helmet");
41
+
40
42
  var toobusy = require("toobusy-js");
41
43
  toobusy.maxLag(500); // 500 ms lag in event queue, quite high but usable for now
42
44
  toobusy.interval(250);
@@ -585,6 +587,39 @@ var startSlave = function(config, afterStartFn)
585
587
  if (!process.env.CLOUDCMS_STANDALONE_HOST) {
586
588
  process.env.CLOUDCMS_STANDALONE_HOST = "local";
587
589
  }
590
+
591
+
592
+ // auto-configuration for HTTPS
593
+ if (!process.configuration.https) {
594
+ process.configuration.https = {};
595
+ }
596
+ if (process.env.CLOUDCMS_HTTPS) {
597
+ process.configuration.https = JSON.parse(process.env.CLOUDCMS_HTTPS);
598
+ }
599
+ if (process.env.CLOUDCMS_HTTPS_KEY_FILEPATH) {
600
+ process.configuration.https.key = fs.readFileSync(process.env.CLOUDCMS_HTTPS_KEY_FILEPATH);
601
+ }
602
+ if (process.env.CLOUDCMS_HTTPS_CERT_FILEPATH) {
603
+ process.configuration.https.cert = fs.readFileSync(process.env.CLOUDCMS_HTTPS_CERT_FILEPATH);
604
+ }
605
+ if (process.env.CLOUDCMS_HTTPS_PFX_FILEPATH) {
606
+ process.configuration.https.pfx = fs.readFileSync(process.env.CLOUDCMS_HTTPS_PFX_FILEPATH);
607
+ }
608
+ if (process.env.CLOUDCMS_HTTPS_PASSPHRASE) {
609
+ process.configuration.https.passphrase = process.env.CLOUDCMS_HTTPS_PASSPHRASE;
610
+ }
611
+ if (process.env.CLOUDCMS_HTTPS_REQUEST_CERT === "true") {
612
+ process.configuration.https.requestCert = true;
613
+ }
614
+ if (process.env.CLOUDCMS_HTTPS_CA_FILEPATH) {
615
+ process.configuration.https.ca = [ fs.readFileSync(process.env.CLOUDCMS_HTTPS_CA_FILEPATH) ];
616
+ }
617
+
618
+ // if https config is empty, remove it
619
+ if (Object.keys(process.configuration.https).length === 0) {
620
+ delete process.configuration.https;
621
+ }
622
+
588
623
 
589
624
  // session store
590
625
  var initializedSession = null;
@@ -1045,8 +1080,17 @@ var startSlave = function(config, afterStartFn)
1045
1080
  ////////////////////////////////////////////////////////////////////////////
1046
1081
 
1047
1082
 
1048
- // CORE OBJECTS
1049
- var server = http.Server(app);
1083
+ // create the server (either HTTP or HTTPS)
1084
+ var server = null;
1085
+ if (process.configuration.https) {
1086
+ // configure helmet to support auto-upgrade of http->https
1087
+ app.use(helmet());
1088
+ // create https server
1089
+ server = https.createServer(process.configuration.https, app);
1090
+ } else {
1091
+ // legacy
1092
+ server = http.Server(app);
1093
+ }
1050
1094
 
1051
1095
  // request timeout
1052
1096
  var requestTimeout = 30000; // 30 seconds
@@ -69,6 +69,10 @@ server.report(function(callback) {
69
69
  console.log("Hosts Directory: " + process.env.CLOUDCMS_HOSTS_PATH);
70
70
  console.log("LaunchPad Mode: " + process.env.CLOUDCMS_LAUNCHPAD_SETUP);
71
71
  console.log("Max Files Detected: " + process.env.CLOUDCMS_MAX_FILES);
72
+
73
+ if (process.configuration.https) {
74
+ console.log("Server is configured to use HTTPS");
75
+ }
72
76
 
73
77
  console.log("");
74
78