@tiledesk/tiledesk-server 2.4.32 → 2.4.34
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/app.js +42 -2
- package/middleware/passport.js +11 -3
- package/package.json +4 -3
- package/routes/files.js +1 -1
package/app.js
CHANGED
|
@@ -72,6 +72,7 @@ var connection = mongoose.connect(databaseUri, { "useNewUrlParser": true, "autoI
|
|
|
72
72
|
winston.error('Failed to connect to MongoDB on ' + databaseUri + " ", err);
|
|
73
73
|
process.exit(1);
|
|
74
74
|
}
|
|
75
|
+
winston.info("Mongoose connection done on host: "+mongoose.connection.host + " on port: " + mongoose.connection.port + " with name: "+ mongoose.connection.name)// , mongoose.connection.db);
|
|
75
76
|
});
|
|
76
77
|
if (process.env.MONGOOSE_DEBUG==="true") {
|
|
77
78
|
mongoose.set('debug', true);
|
|
@@ -133,6 +134,7 @@ var schemaMigrationService = require('./services/schemaMigrationService');
|
|
|
133
134
|
var RouterLogger = require('./models/routerLogger');
|
|
134
135
|
var cacheEnabler = require("./services/cacheEnabler");
|
|
135
136
|
const session = require('express-session');
|
|
137
|
+
const RedisStore = require("connect-redis").default
|
|
136
138
|
|
|
137
139
|
require('./services/mongoose-cache-fn')(mongoose);
|
|
138
140
|
|
|
@@ -275,11 +277,49 @@ app.use(passport.initialize());
|
|
|
275
277
|
if (process.env.DISABLE_SESSION_STRATEGY==true || process.env.DISABLE_SESSION_STRATEGY=="true" ) {
|
|
276
278
|
winston.info("Express Session disabled");
|
|
277
279
|
} else {
|
|
280
|
+
|
|
278
281
|
// https://www.npmjs.com/package/express-session
|
|
279
282
|
let sessionSecret = process.env.SESSION_SECRET || "tiledesk-session-secret";
|
|
280
|
-
|
|
281
|
-
|
|
283
|
+
|
|
284
|
+
if (process.env.ENABLE_REDIS_SESSION==true || process.env.ENABLE_REDIS_SESSION=="true" ) {
|
|
285
|
+
|
|
286
|
+
// Initialize client.
|
|
287
|
+
// let redisClient = createClient()
|
|
288
|
+
// redisClient.connect().catch(console.error)
|
|
289
|
+
|
|
290
|
+
let cacheClient = undefined;
|
|
291
|
+
if (pubModulesManager.cache) {
|
|
292
|
+
cacheClient = pubModulesManager.cache._cache._cache; //_cache._cache to jump directly to redis modules without cacheoose wrapper (don't support await)
|
|
293
|
+
}
|
|
294
|
+
// winston.info("Express Session cacheClient",cacheClient);
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
let redisStore = new RedisStore({
|
|
298
|
+
client: cacheClient,
|
|
299
|
+
prefix: "sessions:",
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
app.use(
|
|
304
|
+
session({
|
|
305
|
+
store: redisStore,
|
|
306
|
+
resave: false, // required: force lightweight session keep alive (touch)
|
|
307
|
+
saveUninitialized: false, // recommended: only save session when data exists
|
|
308
|
+
secret: sessionSecret
|
|
309
|
+
})
|
|
310
|
+
)
|
|
311
|
+
winston.info("Express Session with Redis enabled with Secret: " + sessionSecret);
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
} else {
|
|
315
|
+
app.use(session({ secret: sessionSecret}));
|
|
316
|
+
winston.info("Express Session enabled with Secret: " + sessionSecret);
|
|
317
|
+
|
|
318
|
+
}
|
|
319
|
+
|
|
282
320
|
app.use(passport.session());
|
|
321
|
+
|
|
322
|
+
|
|
283
323
|
}
|
|
284
324
|
|
|
285
325
|
//ATTENTION. If you use AWS Api Gateway you need also to configure the cors policy https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors-console.html
|
package/middleware/passport.js
CHANGED
|
@@ -459,7 +459,8 @@ if (enableGoogleSignin==true) {
|
|
|
459
459
|
passport.use(new GoogleStrategy({
|
|
460
460
|
clientID: googleClientId,
|
|
461
461
|
clientSecret: googleClientSecret,
|
|
462
|
-
callbackURL: googleCallbackURL // 'https://www.example.com/oauth2/redirect/google'
|
|
462
|
+
callbackURL: googleCallbackURL, // 'https://www.example.com/oauth2/redirect/google'
|
|
463
|
+
// stateless: true ????
|
|
463
464
|
},
|
|
464
465
|
function(issuer, profile, cb) {
|
|
465
466
|
|
|
@@ -538,8 +539,15 @@ if (enableGoogleSignin==true) {
|
|
|
538
539
|
return cb(null, savedUser);
|
|
539
540
|
});
|
|
540
541
|
}).catch(function(err) {
|
|
541
|
-
|
|
542
|
-
|
|
542
|
+
// if (err.code == 11000) {
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
// } else {
|
|
547
|
+
winston.error("Error signup google ", err);
|
|
548
|
+
return cb(err);
|
|
549
|
+
// }
|
|
550
|
+
|
|
543
551
|
});
|
|
544
552
|
} else {
|
|
545
553
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-server",
|
|
3
3
|
"description": "The Tiledesk server module",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.34",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node ./bin/www",
|
|
7
7
|
"pretest": "mongodb-runner start",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"tiledesk-server": "./bin/www"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
+
"@tiledesk-ent/tiledesk-server-enterprise": "^1.0.0",
|
|
32
33
|
"@tiledesk-ent/tiledesk-server-jwthistory": "^1.1.9",
|
|
33
34
|
"@tiledesk-ent/tiledesk-server-payments": "^1.1.12",
|
|
34
35
|
"@tiledesk-ent/tiledesk-server-request-history": "^1.1.5",
|
|
35
|
-
"@tiledesk-ent/tiledesk-server-visitorcounter": "^1.1.1"
|
|
36
|
-
"@tiledesk-ent/tiledesk-server-enterprise": "^1.0.0"
|
|
36
|
+
"@tiledesk-ent/tiledesk-server-visitorcounter": "^1.1.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@tiledesk/tiledesk-apps": "^1.0.16",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"bcrypt-nodejs": "0.0.3",
|
|
52
52
|
"body-parser": "^1.20.0",
|
|
53
53
|
"cachegoose": "^8.0.0",
|
|
54
|
+
"connect-redis": "^7.1.0",
|
|
54
55
|
"cookie-parser": "^1.4.6",
|
|
55
56
|
"cors": "^2.8.5",
|
|
56
57
|
"csv-express": "^1.2.2",
|
package/routes/files.js
CHANGED
|
@@ -81,7 +81,7 @@ router.get("/download", (req, res) => {
|
|
|
81
81
|
winston.debug('path', req.query.path);
|
|
82
82
|
// if (path.indexOf("/users/"))
|
|
83
83
|
let filename = pathlib.basename(req.query.path);
|
|
84
|
-
winston.
|
|
84
|
+
winston.debug("filename:"+filename);
|
|
85
85
|
|
|
86
86
|
res.attachment(filename);
|
|
87
87
|
fileService.getFileDataAsStream(req.query.path).pipe(res);
|