Add support for logoutOnIdleSessionTimeout (#6773)

Martin Mädler committed Feb 12, 2025 at 11:04 UTC 9d4f51e970cd6da6e35910ea9f3136aad3b398ba
7 files changed +32 -5
meshcentral-config-schema.json
+5
@@ -2180,6 +2180,11 @@
2180 "default": null,
2181 "description": "When set, idle users will be disconnected after a set amounts of minutes."
2182 },
2183 + "logoutOnIdleSessionTimeout": {
2184 + "type": "boolean",
2185 + "default": true,
2186 + "description": "Determines whether MeshCentral should logout after the session idle timeout elapsed or should just disconnect remote desktop, terminal and files."
2187 + },
2188 "userConsentFlags": {
2189 "type": "object",
2190 "description": "Use this section to require user consent for this domain.",
meshuser.js
+7 -1
@@ -600,7 +600,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
600 }
601 }
602 if (typeof domain.userconsentflags == 'number') { serverinfo.consent = domain.userconsentflags; }
603 - if ((typeof domain.usersessionidletimeout == 'number') && (domain.usersessionidletimeout > 0)) { serverinfo.timeout = (domain.usersessionidletimeout * 60 * 1000); }
603 + if ((typeof domain.usersessionidletimeout == 'number') && (domain.usersessionidletimeout > 0)) {serverinfo.timeout = (domain.usersessionidletimeout * 60 * 1000); }
604 + if (typeof domain.logoutOnIdleSessionTimeout == 'boolean') {
605 + serverinfo.logoutOnIdleSessionTimeout = domain.logoutOnIdleSessionTimeout;
606 + } else {
607 + // Default
608 + serverinfo.logoutOnIdleSessionTimeout = true;
609 + }
610 if (user.siteadmin === SITERIGHT_ADMIN) {
611 if (parent.parent.config.settings.managealldevicegroups.indexOf(user._id) >= 0) { serverinfo.manageAllDeviceGroups = true; }
612 if (obj.crossDomain === true) { serverinfo.crossDomain = []; for (var i in parent.parent.config.domains) { serverinfo.crossDomain.push(i); } }
sample-config-advanced.json
+2
@@ -386,6 +386,8 @@
386 "_agentBlockedIP": "127.0.0.1,::1",
387 "___userSessionIdleTimeout__": "Number of user idle minutes before auto-disconnect",
388 "_userSessionIdleTimeout": 30,
389 + "___logoutOnIdleSessionTimeout": "Determines whether MeshCentral should logout after the session idle timeout elapsed or should just disconnect remote desktop, terminal and files.",
390 + "_logoutOnIdleSessionTimeout": false,
391 "userConsentFlags": {
392 "desktopnotify": true,
393 "terminalnotify": true,
views/default-mobile.handlebars
+6 -1
@@ -1522,7 +1522,12 @@
1522 }
1523
1524 function setSessionActivity() { sessionActivity = Date.now(); }
1525 - function checkIdleSessionTimeout() { var delta = (Date.now() - sessionActivity); if (delta > serverinfo.timeout) { window.location.href = 'logout'; } }
1525 + function checkIdleSessionTimeout() {
1526 + var delta = (Date.now() - sessionActivity);
1527 + if (delta > serverinfo.timeout && serverinfo.logoutOnIdleSessionTimeout) {
1528 + window.location.href = 'logout';
1529 + }
1530 + }
1531
1532 function onMessage(server, message) {
1533 switch (message.action) {
views/default.handlebars
+3 -1
@@ -2447,7 +2447,9 @@
2447 files.Stop();
2448 files = null;
2449 }
2450 - window.location.href = 'logout';
2450 + if (serverinfo.logoutOnIdleSessionTimeout) {
2451 + window.location.href = 'logout';
2452 + }
2453 } else {
2454 var ds = Math.round((serverinfo.timeout - delta) / 1000);
2455 if (ds <= 60) {
views/default3.handlebars
+3 -1
@@ -2897,7 +2897,9 @@
2897 files.Stop();
2898 files = null;
2899 }
2900 - window.location.href = 'logout';
2900 + if (serverinfo.logoutOnIdleSessionTimeout) {
2901 + window.location.href = 'logout';
2902 + }
2903 } else {
2904 var ds = Math.round((serverinfo.timeout - delta) / 1000);
2905 if (ds <= 60) {
views/sharing-mobile.handlebars
+6 -1
@@ -820,7 +820,12 @@
820 }
821
822 function setSessionActivity() { sessionActivity = Date.now(); }
823 - function checkIdleSessionTimeout() { var delta = (Date.now() - sessionActivity); if (delta > serverinfo.timeout) { window.location.href = 'logout'; } }
823 + function checkIdleSessionTimeout() {
824 + var delta = (Date.now() - sessionActivity);
825 + if (delta > serverinfo.timeout && serverinfo.logoutOnIdleSessionTimeout) {
826 + window.location.href = 'logout';
827 + }
828 + }
829
830 //
831 // Menu System