cloudcms-server 0.9.255 → 0.9.260
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/README.md +1 -1
- package/broadcast/providers/redis.js +24 -49
- package/clients/nrp.js +117 -0
- package/clients/redis.js +64 -0
- package/launchpad/index.js +161 -11
- package/launchpad/launchers/cluster.js +87 -109
- package/launchpad/launchers/redis.js +53 -0
- package/launchpad/launchers/single.js +30 -22
- package/locks/locks.js +4 -3
- package/locks/providers/cluster.js +1 -1
- package/locks/providers/memory.js +1 -1
- package/locks/providers/redis.js +62 -82
- package/middleware/admin/admin.js +2 -2
- package/middleware/authentication/providers/saml.js +2 -1
- package/middleware/awareness/awareness.js +12 -2
- package/middleware/awareness/providers/redis.js +225 -199
- package/middleware/cache/providers/redis.js +127 -89
- package/middleware/cloudcms/cloudcms.js +5 -1
- package/middleware/proxy/proxy.js +2 -1
- package/middleware/stores/stores.js +2 -2
- package/middleware/virtual-config/virtual-config.js +4 -4
- package/middleware/wcm/wcm.js +4 -4
- package/package.json +10 -6
- package/server/index.js +624 -592
- package/temp/clusterlock/index.js +2 -0
- package/temp/passport-saml/LICENSE +23 -0
- package/temp/passport-saml/README.md +406 -0
- package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
- package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
- package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/index.js +6 -0
- package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
- package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
- package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
- package/temp/passport-saml/lib/node-saml/types.js +8 -0
- package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/utility.js +19 -0
- package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
- package/temp/passport-saml/lib/node-saml/xml.js +140 -0
- package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
- package/temp/passport-saml/lib/passport-saml/index.js +11 -0
- package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
- package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
- package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
- package/temp/passport-saml/lib/passport-saml/types.js +11 -0
- package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
- package/temp/passport-saml/package.json +96 -0
- package/util/auth.js +1 -1
- package/util/cloudcms.js +6 -6
- package/util/proxy-factory.js +22 -7
- package/util/redis.js +113 -0
- package/util/util.js +1 -1
- package/launchpad/launchers/sticky-cluster.js +0 -43
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { Server } = require("socket.io");
|
|
2
|
+
const { setupWorker } = require("@socket.io/sticky");
|
|
3
|
+
const { createAdapter } = require("@socket.io/cluster-adapter");
|
|
4
|
+
const redisHelper = require("../../util/redis");
|
|
5
|
+
|
|
6
|
+
const clusterLauncherFactory = require("./cluster");
|
|
7
|
+
|
|
8
|
+
module.exports = function(config) {
|
|
9
|
+
|
|
10
|
+
var clusterLauncher = clusterLauncherFactory(config);
|
|
11
|
+
|
|
12
|
+
var r = {};
|
|
13
|
+
|
|
14
|
+
r.startCluster = function(httpServer, callback)
|
|
15
|
+
{
|
|
16
|
+
clusterLauncher.startCluster(httpServer, callback);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
r.afterStartCluster = function(httpServer, callback)
|
|
20
|
+
{
|
|
21
|
+
clusterLauncher.afterStartCluster(httpServer, callback);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
r.afterStartServer = function(app, httpServer, callback)
|
|
25
|
+
{
|
|
26
|
+
const io = new Server(httpServer);
|
|
27
|
+
|
|
28
|
+
(async function() {
|
|
29
|
+
var redisOptions = redisHelper.redisOptions({}, "CLOUDCMS_CLUSTER");
|
|
30
|
+
await redisHelper.createAndConnect(redisOptions, function(err, _client) {
|
|
31
|
+
|
|
32
|
+
const pubClient = _client;
|
|
33
|
+
const subClient = pubClient.duplicate();
|
|
34
|
+
|
|
35
|
+
io.adapter(createAdapter(pubClient, subClient));
|
|
36
|
+
//io.listen(httpServerPort);
|
|
37
|
+
|
|
38
|
+
io.on("connection", (socket) => {
|
|
39
|
+
// TODO
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// setup connection with the primary process
|
|
43
|
+
setupWorker(io);
|
|
44
|
+
|
|
45
|
+
httpServer.io = io;
|
|
46
|
+
|
|
47
|
+
return callback();
|
|
48
|
+
});
|
|
49
|
+
})();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
const { Server } = require("socket.io");
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
3
|
+
module.exports = function(config) {
|
|
4
|
+
|
|
5
|
+
var r = {};
|
|
6
|
+
|
|
7
|
+
r.startCluster = function(httpServer, callback)
|
|
8
|
+
{
|
|
9
|
+
callback();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
r.afterStartCluster = function(httpServer, callback)
|
|
13
|
+
{
|
|
14
|
+
callback();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
r.afterStartServer = function(app, httpServer, callback)
|
|
18
|
+
{
|
|
19
|
+
var io = new Server(httpServer);
|
|
20
|
+
|
|
21
|
+
io.on("connection", (socket) => {
|
|
22
|
+
// TODO
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
httpServer.io = io;
|
|
26
|
+
|
|
27
|
+
callback();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return r;
|
|
31
|
+
}
|
package/locks/locks.js
CHANGED
|
@@ -34,7 +34,8 @@ exports = module.exports = function()
|
|
|
34
34
|
var self = this;
|
|
35
35
|
|
|
36
36
|
// set up defaults
|
|
37
|
-
if (!process.env.CLOUDCMS_LOCKS_TYPE)
|
|
37
|
+
if (!process.env.CLOUDCMS_LOCKS_TYPE)
|
|
38
|
+
{
|
|
38
39
|
process.env.CLOUDCMS_LOCKS_TYPE = "memory";
|
|
39
40
|
|
|
40
41
|
if (process.configuration.setup !== "single") {
|
|
@@ -71,8 +72,8 @@ exports = module.exports = function()
|
|
|
71
72
|
*/
|
|
72
73
|
var lock = r.lock = function(key, fn)
|
|
73
74
|
{
|
|
74
|
-
provider.lock(key, function(releaseFn) {
|
|
75
|
-
fn(function(afterReleaseCallback) {
|
|
75
|
+
provider.lock(key, function(err, releaseFn) {
|
|
76
|
+
fn(err, function(afterReleaseCallback) {
|
|
76
77
|
|
|
77
78
|
releaseFn();
|
|
78
79
|
|
package/locks/providers/redis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const redisHelper = require("../../util/redis");
|
|
2
|
+
|
|
3
|
+
const IORedis = require("ioredis");
|
|
4
|
+
var Redlock = require("redlock");
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Redis lock service.
|
|
@@ -9,98 +10,77 @@ var logFactory = require("../../util/logger");
|
|
|
9
10
|
*/
|
|
10
11
|
exports = module.exports = function(locksConfig)
|
|
11
12
|
{
|
|
12
|
-
var
|
|
13
|
-
redisLock.setDefaults({
|
|
14
|
-
timeout: 200000,
|
|
15
|
-
retries: 2000,
|
|
16
|
-
delay: 50
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var nrp = null;
|
|
13
|
+
var redlock = null;
|
|
20
14
|
var client = null;
|
|
21
|
-
|
|
22
|
-
var logger =
|
|
23
|
-
|
|
24
|
-
// allow for global redis default
|
|
25
|
-
// allow for redis broadcast specific
|
|
26
|
-
// otherwise default to error
|
|
27
|
-
if (typeof(process.env.CLOUDCMS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
28
|
-
logger.setLevel(("" + process.env.CLOUDCMS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
29
|
-
}
|
|
30
|
-
else if (typeof(process.env.CLOUDCMS_LOCKS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
31
|
-
logger.setLevel(("" + process.env.CLOUDCMS_LOCKS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
logger.setLevel("error");
|
|
35
|
-
}
|
|
36
|
-
|
|
15
|
+
|
|
16
|
+
var logger = redisHelper.redisLogger("REDIS_LOCKS", "CLOUDCMS_LOCKS_", "error")
|
|
17
|
+
|
|
37
18
|
var r = {};
|
|
38
19
|
|
|
39
20
|
r.init = function(callback)
|
|
40
21
|
{
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
client = redis.createClient(redisPort, redisEndpoint, redisOptions);
|
|
22
|
+
var redisOptions = redisHelper.redisOptions(locksConfig);
|
|
23
|
+
client = new IORedis(redisOptions.url);
|
|
24
|
+
|
|
25
|
+
redlock = new Redlock(
|
|
26
|
+
[client],
|
|
27
|
+
{
|
|
28
|
+
// the expected clock drift; for more details
|
|
29
|
+
// see http://redis.io/topics/distlock
|
|
30
|
+
driftFactor: 0.01, // multiplied by lock ttl to determine drift time
|
|
31
|
+
|
|
32
|
+
// the max number of times Redlock will attempt
|
|
33
|
+
// to lock a resource before erroring
|
|
34
|
+
retryCount: 10,
|
|
35
|
+
|
|
36
|
+
// the time in ms between attempts
|
|
37
|
+
retryDelay: 200, // time in ms
|
|
38
|
+
|
|
39
|
+
// the max time in ms randomly added to retries
|
|
40
|
+
// to improve performance under high contention
|
|
41
|
+
// see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
|
42
|
+
retryJitter: 200 // time in ms
|
|
43
|
+
}
|
|
44
|
+
);
|
|
66
45
|
|
|
67
|
-
callback();
|
|
46
|
+
return callback();
|
|
68
47
|
};
|
|
69
48
|
|
|
70
49
|
r.lock = function(key, fn)
|
|
71
50
|
{
|
|
51
|
+
key = key.trim();
|
|
52
|
+
key = key.toLowerCase();
|
|
53
|
+
key = key.replace(/[\W_]+/g,"");
|
|
54
|
+
|
|
72
55
|
var lockKey = "cloudcms:locks:write:" + key;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
logger.info("lock.release - " + lockKey);
|
|
79
|
-
lock.release(function(err) {
|
|
80
|
-
|
|
81
|
-
if (err) {
|
|
82
|
-
console.log("Failed to release redis lock: " + lockKey);
|
|
83
|
-
console.log("Error: " + err);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
logger.info("lock.released - " + lockKey);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}(lock, lockKey);
|
|
91
|
-
|
|
92
|
-
logger.info("lock.acquire - " + lockKey);
|
|
93
|
-
lock.acquire(lockKey, function(err) {
|
|
94
|
-
|
|
56
|
+
|
|
57
|
+
logger.debug("lock.acquire:", lockKey);
|
|
58
|
+
|
|
59
|
+
redlock.lock(lockKey, 2000, function(err, lock) {
|
|
60
|
+
|
|
95
61
|
if (err) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return;
|
|
62
|
+
logger.error("Failed to acquire redis lock:", lockKey, err);
|
|
63
|
+
return fn(err);
|
|
99
64
|
}
|
|
100
|
-
|
|
101
|
-
logger.
|
|
102
|
-
|
|
103
|
-
|
|
65
|
+
|
|
66
|
+
logger.debug("lock.acquired:", lockKey);
|
|
67
|
+
|
|
68
|
+
var releaseCallbackFn = function(lock, lockKey) {
|
|
69
|
+
return function() {
|
|
70
|
+
|
|
71
|
+
logger.debug("lock.release:", lockKey);
|
|
72
|
+
|
|
73
|
+
lock.unlock(function(err) {
|
|
74
|
+
if (err) {
|
|
75
|
+
logger.error("Failed to release redis lock:", lockKey, err);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}(lock, lockKey);
|
|
80
|
+
|
|
81
|
+
logger.debug("lock.invokeFn");
|
|
82
|
+
fn(null, releaseCallbackFn);
|
|
83
|
+
|
|
104
84
|
});
|
|
105
85
|
};
|
|
106
86
|
|
|
@@ -18,7 +18,7 @@ exports = module.exports = function()
|
|
|
18
18
|
{
|
|
19
19
|
var z = ref.indexOf("://");
|
|
20
20
|
|
|
21
|
-
var type = ref.substring(0, z
|
|
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
|
|
|
@@ -458,7 +458,12 @@ exports = module.exports = function()
|
|
|
458
458
|
{
|
|
459
459
|
// take out a cluster-wide lock on the "channelId"
|
|
460
460
|
// so that two "threads" can't acquire/release at the same time for a given channel
|
|
461
|
-
_LOCK(channelId, function (releaseLockFn) {
|
|
461
|
+
_LOCK(channelId, function (err, releaseLockFn) {
|
|
462
|
+
|
|
463
|
+
if (err) {
|
|
464
|
+
return callback(err);
|
|
465
|
+
}
|
|
466
|
+
|
|
462
467
|
provider.acquireLock(channelId, user, function(err, success) {
|
|
463
468
|
releaseLockFn();
|
|
464
469
|
callback(err, success);
|
|
@@ -477,7 +482,12 @@ exports = module.exports = function()
|
|
|
477
482
|
{
|
|
478
483
|
// take out a cluster-wide lock on the "channelId"
|
|
479
484
|
// so that two "threads" can't acquire/release at the same time for a given channel
|
|
480
|
-
_LOCK(channelId, function (releaseLockFn) {
|
|
485
|
+
_LOCK(channelId, function (err, releaseLockFn) {
|
|
486
|
+
|
|
487
|
+
if (err) {
|
|
488
|
+
return callback(err);
|
|
489
|
+
}
|
|
490
|
+
|
|
481
491
|
provider.releaseLock(channelId, userId, function(err, success) {
|
|
482
492
|
releaseLockFn();
|
|
483
493
|
callback(err, success);
|