cloudcms-server 3.3.1-beta.8 → 4.0.0-beta.1

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.
Files changed (109) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/broadcast/broadcast.js +6 -3
  4. package/broadcast/providers/redis.js +24 -49
  5. package/clients/nrp.js +117 -0
  6. package/clients/redis.js +64 -0
  7. package/d1/index.js +629 -0
  8. package/d1/index.js.works +203 -0
  9. package/d1/package.json +86 -0
  10. package/d1/package.json.works +14 -0
  11. package/duster/helpers/sample/nyt.js +2 -1
  12. package/framework/controllers.js +4 -4
  13. package/index.js +26 -14
  14. package/insight/insight.js +1 -1
  15. package/launchpad/index.js +203 -11
  16. package/launchpad/launchers/cluster.js +103 -110
  17. package/launchpad/launchers/redis.js +70 -0
  18. package/launchpad/launchers/single.js +36 -22
  19. package/locks/locks.js +63 -9
  20. package/locks/providers/cluster.js +3 -1
  21. package/locks/providers/memory.js +10 -7
  22. package/locks/providers/redis.js +62 -82
  23. package/middleware/admin/admin.js +3 -3
  24. package/middleware/authentication/adapters/session.js +11 -8
  25. package/middleware/authentication/authentication.js +28 -16
  26. package/middleware/authentication/authenticators/default.js +5 -2
  27. package/middleware/authentication/authenticators/session.js +5 -2
  28. package/middleware/authentication/providers/saml.js +1 -1
  29. package/middleware/authorization/authorization.js +11 -8
  30. package/middleware/awareness/awareness.js +55 -31
  31. package/middleware/awareness/plugins/editorial.js +4 -4
  32. package/middleware/awareness/providers/abstract-async.js +107 -84
  33. package/middleware/awareness/providers/abstract.js +1 -1
  34. package/middleware/awareness/providers/memory.js +0 -14
  35. package/middleware/awareness/providers/redis.js +186 -279
  36. package/middleware/cache/cache.js +4 -2
  37. package/middleware/cache/providers/redis.js +127 -89
  38. package/middleware/cache/providers/shared-memory.js +3 -3
  39. package/middleware/cloudcms/cloudcms.js +22 -16
  40. package/middleware/form/form.js +3 -3
  41. package/middleware/modules/modules.js +63 -10
  42. package/middleware/proxy/proxy.js +8 -21
  43. package/middleware/stores/stores.js +48 -5
  44. package/middleware/themes/themes.js +49 -0
  45. package/middleware/virtual-config/virtual-config.js +11 -8
  46. package/middleware/wcm/wcm.js +4 -4
  47. package/notifications/notifications.js +27 -4
  48. package/package.json +30 -25
  49. package/server/index.js +508 -412
  50. package/server/standalone.js +9 -0
  51. package/temp/clusterlock/index.js +3 -3
  52. package/temp/clusterlock/package.json +1 -1
  53. package/temp/passport-saml/LICENSE +23 -0
  54. package/temp/passport-saml/README.md +406 -0
  55. package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
  56. package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
  57. package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
  58. package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
  59. package/temp/passport-saml/lib/node-saml/index.js +6 -0
  60. package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
  61. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
  62. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
  63. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
  64. package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
  65. package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
  66. package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
  67. package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
  68. package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
  69. package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
  70. package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
  71. package/temp/passport-saml/lib/node-saml/types.js +8 -0
  72. package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
  73. package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
  74. package/temp/passport-saml/lib/node-saml/utility.js +19 -0
  75. package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
  76. package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
  77. package/temp/passport-saml/lib/node-saml/xml.js +140 -0
  78. package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
  79. package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
  80. package/temp/passport-saml/lib/passport-saml/index.js +11 -0
  81. package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
  82. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
  83. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
  84. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
  85. package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
  86. package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
  87. package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
  88. package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
  89. package/temp/passport-saml/lib/passport-saml/types.js +11 -0
  90. package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
  91. package/temp/passport-saml/package.json +96 -0
  92. package/util/auth.js +6 -6
  93. package/util/cloudcms.js +85 -88
  94. package/util/proxy-factory.js +159 -268
  95. package/util/redis.js +113 -0
  96. package/util/renditions.js +12 -6
  97. package/util/request.js +48 -12
  98. package/util/util.js +16 -2
  99. package/launchpad/launchers/sticky-cluster.js +0 -43
  100. package/temp/memored/.jshintrc +0 -4
  101. package/temp/memored/README.md +0 -240
  102. package/temp/memored/demo/demo1.js +0 -37
  103. package/temp/memored/demo/demo2.js +0 -32
  104. package/temp/memored/gulpfile.js +0 -8
  105. package/temp/memored/index.js +0 -343
  106. package/temp/memored/package.json +0 -54
  107. package/temp/memored/spec/memored.spec.js +0 -265
  108. package/web/cms/ice.js +0 -109
  109. package/web/cms/preview.js +0 -106
@@ -17,8 +17,8 @@ exports = module.exports = function()
17
17
  if (ref)
18
18
  {
19
19
  var z = ref.indexOf("://");
20
-
21
- var type = ref.substring(0, z + 3);
20
+
21
+ var type = ref.substring(0, z);
22
22
  var identifier = ref.substring(z + 3);
23
23
 
24
24
  var parts = identifier.split("/").reverse();
@@ -132,7 +132,7 @@ exports = module.exports = function()
132
132
  {
133
133
  assertAuthenticated(req, res, function() {
134
134
 
135
- doResetCache(req.virtualHost, req.ref, function(err) {
135
+ doResetCache(req.virtualHost, req.query.ref, function(err) {
136
136
  completionFn(req.virtualHost, res, err);
137
137
  });
138
138
 
@@ -9,15 +9,18 @@ class SessionAdapter extends AbstractAdapter
9
9
 
10
10
  identify(req, callback)
11
11
  {
12
- if (req.session && req.session._auth_profile)
12
+ if (req.session)
13
13
  {
14
- var properties = {
15
- "token": req.session._auth_profile.unique_name,
16
- "trusted": true,
17
- "profile": req.session._auth_profile
18
- };
19
-
20
- return callback(null, properties);
14
+ if (req.session._auth_profile)
15
+ {
16
+ var properties = {
17
+ "token": req.session._auth_profile.unique_name,
18
+ "trusted": true,
19
+ "profile": req.session._auth_profile
20
+ };
21
+
22
+ return callback(null, properties);
23
+ }
21
24
  }
22
25
 
23
26
  return super.identify(req, callback);
@@ -436,15 +436,21 @@ exports = module.exports = function()
436
436
  }
437
437
  else
438
438
  {
439
- req.session.registration_strategy_id = strategyId;
440
- req.session.registration_user_object = userObject;
441
- req.session.registration_user_identifier = userIdentifier;
442
- req.session.registration_groups_array = groupsArray;
443
- req.session.registration_mandatory_groups_array = mandatoryGroupsArray;
444
- req.session.registration_token = info.token;
445
- req.session.registration_refresh_token = info.refresh_token;
446
-
447
- return res.redirect(registrationRedirectUrl);
439
+ return req.session.reload(function() {
440
+
441
+ req.session.registration_strategy_id = strategyId;
442
+ req.session.registration_user_object = userObject;
443
+ req.session.registration_user_identifier = userIdentifier;
444
+ req.session.registration_groups_array = groupsArray;
445
+ req.session.registration_mandatory_groups_array = mandatoryGroupsArray;
446
+ req.session.registration_token = info.token;
447
+ req.session.registration_refresh_token = info.refresh_token;
448
+
449
+ req.session.save(function() {
450
+ res.redirect(registrationRedirectUrl);
451
+ });
452
+
453
+ });
448
454
  }
449
455
  });
450
456
  }
@@ -765,13 +771,19 @@ exports = module.exports = function()
765
771
  }
766
772
  else
767
773
  {
768
- req.session.registration_strategy_id = strategyId;
769
- req.session.registration_user_object = properties.user_object;
770
- req.session.registration_user_identifier = properties.user_identifier;
771
- req.session.registration_token = properties.token;
772
- req.session.registration_refresh_token = properties.refresh_token;
773
-
774
- return res.redirect(registrationRedirect);
774
+ return req.session.reload(function() {
775
+
776
+ req.session.registration_strategy_id = strategyId;
777
+ req.session.registration_user_object = properties.user_object;
778
+ req.session.registration_user_identifier = properties.user_identifier;
779
+ req.session.registration_token = properties.token;
780
+ req.session.registration_refresh_token = properties.refresh_token;
781
+
782
+ req.session.save(function() {
783
+ res.redirect(registrationRedirect);
784
+ });
785
+
786
+ });
775
787
  }
776
788
  }
777
789
 
@@ -15,8 +15,11 @@ class DefaultAuthenticator extends AbstractAuthenticator
15
15
  {
16
16
  return req.logIn(gitanaUser, function() {
17
17
 
18
- if (req.session && req.session.save) {
19
- req.session.save();
18
+ if (req.session)
19
+ {
20
+ return req.session.save(function() {
21
+ callback();
22
+ });
20
23
  }
21
24
 
22
25
  callback();
@@ -25,8 +25,11 @@ class SessionAuthenticator extends DefaultAuthenticator
25
25
 
26
26
  req.user = gitanaUser;
27
27
 
28
- if (req.session && req.session.save) {
29
- req.session.save();
28
+ if (req.session)
29
+ {
30
+ return req.session.save(function() {
31
+ callback();
32
+ });
30
33
  }
31
34
 
32
35
  callback();
@@ -1,4 +1,4 @@
1
- var auth = require("../../../util/auth");
1
+ //var auth = require("../../../util/auth");
2
2
 
3
3
  var SamlStrategy = require('passport-saml').Strategy;
4
4
  var AbstractProvider = require("./abstract");
@@ -41,17 +41,20 @@ exports = module.exports = function()
41
41
  }
42
42
  */
43
43
 
44
- if (pathRequiresAuthorization) {
45
- if (req.session && req.session.requestContext) {
46
- next();
47
- }
48
- else {
49
- res.redirect("/login");
50
- }
44
+ if (!pathRequiresAuthorization)
45
+ {
46
+ return next();
51
47
  }
52
- else {
48
+
49
+ if (req.session && req.session.requestContext)
50
+ {
53
51
  next();
54
52
  }
53
+ else
54
+ {
55
+ res.redirect("/login");
56
+ }
57
+
55
58
  });
56
59
  };
57
60
 
@@ -46,8 +46,10 @@ exports = module.exports = function()
46
46
  if (!process.env.CLOUDCMS_AWARENESS_TYPE)
47
47
  {
48
48
  process.env.CLOUDCMS_AWARENESS_TYPE = "memory";
49
-
50
- if (process.configuration.setup !== "single") {
49
+
50
+ // auto-configure
51
+ if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
52
+ {
51
53
  process.env.CLOUDCMS_AWARENESS_TYPE = "redis";
52
54
  }
53
55
  }
@@ -63,10 +65,15 @@ exports = module.exports = function()
63
65
  if (!process.configuration.awareness.config) {
64
66
  process.configuration.awareness.config = {};
65
67
  }
66
-
68
+
69
+ // init any plugins?
70
+ if (!process.configuration.awareness.plugins) {
71
+ process.configuration.awareness.plugins = [];
72
+ }
73
+
67
74
  var type = process.configuration.awareness.type;
68
75
  var config = process.configuration.awareness.config;
69
-
76
+
70
77
  var providerFactory = require("./providers/" + type);
71
78
  provider = new providerFactory(config);
72
79
 
@@ -77,12 +84,6 @@ exports = module.exports = function()
77
84
  return callback(err);
78
85
  }
79
86
 
80
- // init any plugins?
81
- if (!process.configuration.awareness.plugins) {
82
- process.configuration.awareness.plugins = [];
83
- }
84
-
85
-
86
87
  var fns = [];
87
88
  for (var i = 0; i < pluginPaths.length; i++)
88
89
  {
@@ -118,15 +119,18 @@ exports = module.exports = function()
118
119
  /**
119
120
  * This gets called whenever a new socket is connected to the Cloud CMS server.
120
121
  *
122
+ * @param io
123
+ * @param callback
124
+ *
121
125
  * @type {Function}
122
126
  */
123
- var initSocketIO = r.initSocketIO = function(callback) {
124
-
127
+ var initSocketIO = r.initSocketIO = function(io, callback) {
128
+
125
129
  // initialize socket IO event handlers so that awareness binds to any new, incoming sockets
126
- socketInit(process.IO);
130
+ socketInit(io);
127
131
 
128
132
  // ensure the reaper is initialized
129
- reaperInit(process.IO, REAP_FREQUENCY_MS, REAP_MAX_AGE_MS, function(err) {
133
+ reaperInit(io, REAP_FREQUENCY_MS, REAP_MAX_AGE_MS, function(err) {
130
134
  callback(err);
131
135
  });
132
136
  };
@@ -175,7 +179,7 @@ exports = module.exports = function()
175
179
  // when a socket.io connection is established, we set up some default listeners for events that the client
176
180
  // may emit to us
177
181
  io.on("connection", function(socket) {
178
-
182
+
179
183
  // "register" -> indicates that a user is in a channel
180
184
  socket.on("register", function(channelId, user, dirty, callback) {
181
185
 
@@ -196,24 +200,32 @@ exports = module.exports = function()
196
200
  return callback(err);
197
201
  }
198
202
 
199
- // if we were already registered, just callback
200
- // however, if "dirty" is set, then we always hand back membership
201
- if (!dirty && alreadyRegistered)
202
- {
203
- return callback();
204
- }
205
-
206
- if (!alreadyRegistered)
207
- {
208
- // logger.info("New registration - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
209
-
203
+ // // if we were already registered, just callback
204
+ // // however, if "dirty" is set, then we always hand back membership
205
+ // if (!dirty && alreadyRegistered)
206
+ // {
207
+ // logger.info("Already registered, not dirty - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
208
+ //
209
+ // return callback();
210
+ // }
211
+ //
212
+ // if (!alreadyRegistered)
213
+ // {
214
+ // logger.info("New registration - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
215
+
216
+ //logger.info("Register - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ")");
210
217
  socket.join(channelId);
211
- }
218
+ //}
212
219
 
213
220
  discover(channelId, function(err, userArray) {
214
221
 
215
- if (!err) {
216
- logger.info("Discover - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ") handing back: " + userArray.length);
222
+ if (err)
223
+ {
224
+ logger.info("Discover - channelId: " + channelId + ", err: " + JSON.stringify(err));
225
+ }
226
+ else
227
+ {
228
+ //logger.info("Discover - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ") handing back: " + userArray.length);
217
229
  io.sockets.in(channelId).emit("membershipChanged", channelId, userArray);
218
230
  }
219
231
 
@@ -415,6 +427,8 @@ exports = module.exports = function()
415
427
  */
416
428
  var register = r.register = function(channelId, user, callback)
417
429
  {
430
+ //console.log("Awareness - heard register, channel: " + channelId + ", user: " + user.id);
431
+
418
432
  provider.register(channelId, user, callback);
419
433
  };
420
434
 
@@ -461,7 +475,12 @@ exports = module.exports = function()
461
475
  {
462
476
  // take out a cluster-wide lock on the "channelId"
463
477
  // so that two "threads" can't acquire/release at the same time for a given channel
464
- _LOCK(channelId, function (releaseLockFn) {
478
+ _LOCK(channelId, function (err, releaseLockFn) {
479
+
480
+ if (err) {
481
+ return callback(err);
482
+ }
483
+
465
484
  provider.acquireLock(channelId, user, function(err, success) {
466
485
  releaseLockFn();
467
486
  callback(err, success);
@@ -480,7 +499,12 @@ exports = module.exports = function()
480
499
  {
481
500
  // take out a cluster-wide lock on the "channelId"
482
501
  // so that two "threads" can't acquire/release at the same time for a given channel
483
- _LOCK(channelId, function (releaseLockFn) {
502
+ _LOCK(channelId, function (err, releaseLockFn) {
503
+
504
+ if (err) {
505
+ return callback(err);
506
+ }
507
+
484
508
  provider.releaseLock(channelId, userId, function(err, success) {
485
509
  releaseLockFn();
486
510
  callback(err, success);
@@ -41,7 +41,7 @@ exports.bindSocket = function(socket, provider)
41
41
  var acquireEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, type, force, callback)
42
42
  {
43
43
  // send an HTTP command to acquire an editorial workspace for this repository and branch
44
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/acquire";
44
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/acquire";
45
45
 
46
46
  var headers = {};
47
47
  //headers["Authorization"] = socket.gitana.platform().getDriver().getHttpHeaders()["Authorization"];
@@ -97,7 +97,7 @@ exports.bindSocket = function(socket, provider)
97
97
  var releaseEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
98
98
  {
99
99
  // send an HTTP command to release the session
100
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/release";
100
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/release";
101
101
 
102
102
  var json = {};
103
103
  json.repositoryId = repositoryId;
@@ -141,7 +141,7 @@ exports.bindSocket = function(socket, provider)
141
141
  */
142
142
  var commitEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
143
143
  {
144
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/commit";
144
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/commit";
145
145
 
146
146
  var json = {};
147
147
  json.repositoryId = repositoryId;
@@ -184,7 +184,7 @@ exports.bindSocket = function(socket, provider)
184
184
  */
185
185
  var editorialWorkspaceInfo = function(socket, provider, sessionKey, repositoryId, branchId, callback)
186
186
  {
187
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/info";
187
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/info";
188
188
 
189
189
  var json = {};
190
190
  json.repositoryId = repositoryId;