cloudcms-server 3.2.324 → 3.2.326
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 +1 -1
- package/server/index.js +73 -15
- package/util/auth.js +25 -23
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -16,8 +16,7 @@ var session = require('express-session');
|
|
|
16
16
|
var cookieParser = require('cookie-parser');
|
|
17
17
|
var flash = require("connect-flash");
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
const connectRedis = require('connect-redis');
|
|
19
|
+
const {RedisStore} = require("connect-redis");
|
|
21
20
|
|
|
22
21
|
// we don't bind a single passport - instead, we get the constructor here by hand
|
|
23
22
|
var Passport = require("passport").Passport;
|
|
@@ -715,7 +714,6 @@ var initSession = function(initDone)
|
|
|
715
714
|
var redisOptions = redisHelper.redisOptions();
|
|
716
715
|
var redisClient = new IORedis(redisOptions.url);
|
|
717
716
|
|
|
718
|
-
var RedisStore = connectRedis(session);
|
|
719
717
|
sessionConfig.store = new RedisStore({ client: redisClient });
|
|
720
718
|
initDone(null, session(sessionConfig));
|
|
721
719
|
}
|
|
@@ -891,14 +889,20 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
891
889
|
next();
|
|
892
890
|
});
|
|
893
891
|
*/
|
|
894
|
-
|
|
892
|
+
|
|
895
893
|
// increment and assign request id
|
|
896
894
|
app.use(function increment_and_assign_id(req, res, next) {
|
|
897
895
|
requestCounter++;
|
|
898
896
|
req.id = requestCounter;
|
|
899
897
|
next();
|
|
900
898
|
});
|
|
901
|
-
|
|
899
|
+
|
|
900
|
+
// DEBUG
|
|
901
|
+
app.use(function requestHit1(req, res, next) {
|
|
902
|
+
console.log("[REQ: " + req.id + "] DEBUG 1");
|
|
903
|
+
next();
|
|
904
|
+
});
|
|
905
|
+
|
|
902
906
|
// APPLY CUSTOM INIT FUNCTIONS
|
|
903
907
|
runFunctions(config.initFunctions, [app], function (err) {
|
|
904
908
|
|
|
@@ -991,7 +995,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
991
995
|
|
|
992
996
|
// common interceptors and config
|
|
993
997
|
main.common1(app);
|
|
994
|
-
|
|
998
|
+
|
|
999
|
+
// DEBUG
|
|
1000
|
+
app.use(function requestHit2(req, res, next) {
|
|
1001
|
+
console.log("[REQ: " + req.id + "] DEBUG 2");
|
|
1002
|
+
next();
|
|
1003
|
+
});
|
|
1004
|
+
|
|
995
1005
|
// general logging of requests
|
|
996
1006
|
// gather statistics on response time
|
|
997
1007
|
app.use(responseTime(function (req, res, time) {
|
|
@@ -1040,7 +1050,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1040
1050
|
|
|
1041
1051
|
// common interceptors and config
|
|
1042
1052
|
main.common2(app);
|
|
1043
|
-
|
|
1053
|
+
|
|
1054
|
+
// DEBUG
|
|
1055
|
+
app.use(function requestHit3(req, res, next) {
|
|
1056
|
+
console.log("[REQ: " + req.id + "] DEBUG 3");
|
|
1057
|
+
next();
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1044
1060
|
// APPLY CUSTOM DRIVER FUNCTIONS
|
|
1045
1061
|
runFunctions(config.driverFunctions, [app], function(err) {
|
|
1046
1062
|
|
|
@@ -1052,7 +1068,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1052
1068
|
|
|
1053
1069
|
// cloudcms things need to run here
|
|
1054
1070
|
main.common4(app, true);
|
|
1055
|
-
|
|
1071
|
+
|
|
1072
|
+
// DEBUG
|
|
1073
|
+
app.use(function requestHit4(req, res, next) {
|
|
1074
|
+
console.log("[REQ: " + req.id + "] DEBUG 4");
|
|
1075
|
+
next();
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1056
1078
|
// APPLY CUSTOM FILTER FUNCTIONS
|
|
1057
1079
|
runFunctions(config.filterFunctions, [app], function (err) {
|
|
1058
1080
|
|
|
@@ -1067,7 +1089,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1067
1089
|
|
|
1068
1090
|
// DEVELOPMENT BASED PERFORMANCE CACHING
|
|
1069
1091
|
main.perf3(app);
|
|
1070
|
-
|
|
1092
|
+
|
|
1093
|
+
// DEBUG
|
|
1094
|
+
app.use(function requestHit5(req, res, next) {
|
|
1095
|
+
console.log("[REQ: " + req.id + "] DEBUG 5");
|
|
1096
|
+
next();
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1071
1099
|
// standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
|
|
1072
1100
|
// that might be JSON (regardless of content type)
|
|
1073
1101
|
app.use(function (req, res, next) {
|
|
@@ -1089,7 +1117,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1089
1117
|
app.use(initializedSession);
|
|
1090
1118
|
app.use(flash());
|
|
1091
1119
|
}
|
|
1092
|
-
|
|
1120
|
+
|
|
1121
|
+
// DEBUG
|
|
1122
|
+
app.use(function requestHit6(req, res, next) {
|
|
1123
|
+
console.log("[REQ: " + req.id + "] DEBUG 6");
|
|
1124
|
+
next();
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1093
1127
|
// this is the same as calling
|
|
1094
1128
|
// app.use(passport.initialize());
|
|
1095
1129
|
// except we create a new passport each time and store on request to support multitenancy
|
|
@@ -1128,7 +1162,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1128
1162
|
req.passport.session()(req, res, next);
|
|
1129
1163
|
});
|
|
1130
1164
|
}
|
|
1131
|
-
|
|
1165
|
+
|
|
1166
|
+
// DEBUG
|
|
1167
|
+
app.use(function requestHit7(req, res, next) {
|
|
1168
|
+
console.log("[REQ: " + req.id + "] DEBUG 7");
|
|
1169
|
+
next();
|
|
1170
|
+
});
|
|
1171
|
+
|
|
1132
1172
|
// welcome files
|
|
1133
1173
|
main.welcome(app);
|
|
1134
1174
|
|
|
@@ -1139,13 +1179,31 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1139
1179
|
|
|
1140
1180
|
// healthcheck middleware
|
|
1141
1181
|
main.healthcheck(app);
|
|
1142
|
-
|
|
1182
|
+
|
|
1183
|
+
// DEBUG
|
|
1184
|
+
app.use(function requestHit8(req, res, next) {
|
|
1185
|
+
console.log("[REQ: " + req.id + "] DEBUG 8");
|
|
1186
|
+
next();
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1143
1189
|
// APPLY CUSTOM ROUTES
|
|
1144
1190
|
runFunctions(config.routeFunctions, [app], function (err) {
|
|
1145
|
-
|
|
1191
|
+
|
|
1192
|
+
// DEBUG
|
|
1193
|
+
app.use(function requestHit9(req, res, next) {
|
|
1194
|
+
console.log("[REQ: " + req.id + "] DEBUG 9");
|
|
1195
|
+
next();
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1146
1198
|
// configure cloudcms app server handlers
|
|
1147
1199
|
main.handlers(app, true);
|
|
1148
|
-
|
|
1200
|
+
|
|
1201
|
+
// DEBUG
|
|
1202
|
+
app.use(function requestHit10(req, res, next) {
|
|
1203
|
+
console.log("[REQ: " + req.id + "] DEBUG 10");
|
|
1204
|
+
next();
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1149
1207
|
// register error functions
|
|
1150
1208
|
runFunctions(config.errorFunctions, [app], function (err) {
|
|
1151
1209
|
|
|
@@ -1163,7 +1221,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1163
1221
|
}
|
|
1164
1222
|
}
|
|
1165
1223
|
runFunctions(allConfigureFunctions, [app], function (err) {
|
|
1166
|
-
|
|
1224
|
+
|
|
1167
1225
|
// create the server (either HTTP or HTTPS)
|
|
1168
1226
|
createHttpServer(app, function(err, httpServer) {
|
|
1169
1227
|
|
package/util/auth.js
CHANGED
|
@@ -5,16 +5,18 @@ var LRUCache = require("lru-cache");
|
|
|
5
5
|
|
|
6
6
|
var request = require("./request");
|
|
7
7
|
|
|
8
|
+
const IsolatedVM = require("isolated-vm");
|
|
9
|
+
|
|
8
10
|
// trusted profile cache size 100
|
|
9
11
|
var TRUSTED_PROFILE_CACHE = new LRUCache({
|
|
10
12
|
max:100,
|
|
11
|
-
|
|
13
|
+
ttl: 1000 * 60 * 15 // 15 minutes
|
|
12
14
|
});
|
|
13
15
|
|
|
14
16
|
// user entry cache size 100
|
|
15
17
|
var USER_ENTRY_CACHE = new LRUCache({
|
|
16
18
|
max: 100,
|
|
17
|
-
|
|
19
|
+
ttl: 1000 * 60 * 15 // 15 minutes
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
var Gitana = require("gitana");
|
|
@@ -652,28 +654,28 @@ var executeRule = function(req, rule, gitanaUser, callback)
|
|
|
652
654
|
});
|
|
653
655
|
};
|
|
654
656
|
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
"addToPlatformTeams": function(teamIdentifiers) {
|
|
670
|
-
return addToPlatformTeams(teamIdentifiers, function() {
|
|
671
|
-
console.log("Added user: " + gitanaUser._doc + " to platform teams: " + JSON.stringify(teamIdentifiers));
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
}
|
|
657
|
+
const isolate = new IsolatedVM.Isolate({ memoryLimit: 32 });
|
|
658
|
+
const context = isolate.createContextSync();
|
|
659
|
+
const jail = context.global;
|
|
660
|
+
|
|
661
|
+
// functions
|
|
662
|
+
jail.setSync('addToProject', function(projectId, teamIdentifiers) {
|
|
663
|
+
return addToProject(projectId, teamIdentifiers, function() {
|
|
664
|
+
console.log("Added user: " + gitanaUser._doc + " to project: " + projectId + ", teams: " + JSON.stringify(teamIdentifiers));
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
jail.setSync("addToPlatformTeam", function(teamIdentifier) {
|
|
668
|
+
return addToPlatformTeams([teamIdentifier], function() {
|
|
669
|
+
console.log("Added user: " + gitanaUser._doc + " to platform team: " + teamIdentifier);
|
|
670
|
+
});
|
|
675
671
|
});
|
|
676
|
-
|
|
672
|
+
jail.setSync("addToPlatformTeams", function(teamIdentifiers) {
|
|
673
|
+
return addToPlatformTeams(teamIdentifiers, function() {
|
|
674
|
+
console.log("Added user: " + gitanaUser._doc + " to platform teams: " + JSON.stringify(teamIdentifiers));
|
|
675
|
+
});
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
context.evalSync(rule);
|
|
677
679
|
|
|
678
680
|
setTimeout(function() {
|
|
679
681
|
callback();
|