Started work on user group session recording. #3127

Ylian Saint-Hilaire committed Sep 13, 2021 at 16:19 UTC 1179f7f63abe38259c6c4d045d8a93cf6011f19e
5 files changed +42 -3
meshcentral-config-schema.json
+1
@@ -677,6 +677,7 @@
677 "additionalProperties": false,
678 "properties": {
679 "onlySelectedUsers": { "type": "boolean", "default": false, "description": "When enabled, only device users with the session recording feature turned on will be recorded. When false, all users are recorded." },
680 + "onlySelectedUserGroups": { "type": "boolean", "default": false, "description": "When enabled, only device user groups with the session recording feature turned on will be recorded. When false, all users are recorded." },
681 "onlySelectedDeviceGroups": { "type": "boolean", "default": false, "description": "When enabled, only device groups with the session recording feature turned on will be recorded. When false, all devices are recorded." },
682 "filepath": { "type": "string", "description": "The file path where recording files are kept." },
683 "index": { "type": "boolean", "default": false, "description": "If true, automatically index remote desktop recordings so that the plays can skip to any place in the file." },
meshuser.js
+11 -2
@@ -505,7 +505,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
505 serverinfo.tlshash = Buffer.from(parent.webCertificateFullHashs[domain.id], 'binary').toString('hex').toUpperCase(); // SHA384 of server HTTPS certificate
506 serverinfo.agentCertHash = parent.agentCertificateHashBase64;
507 if (typeof domain.sessionrecording == 'object') {
508 - if (domain.sessionrecording.onlyselectedusers === true) { serverinfo.usersSessionRecording = 1; } // Allow enabling of session recording for user groups
508 + if (domain.sessionrecording.onlyselectedusers === true) { serverinfo.usersSessionRecording = 1; } // Allow enabling of session recording for users
509 + if (domain.sessionrecording.onlyselectedusergroups === true) { serverinfo.userGroupsSessionRecording = 1; } // Allow enabling of session recording for user groups
510 if (domain.sessionrecording.onlyselecteddevicegroups === true) { serverinfo.devGroupSessionRecording = 1; } // Allow enabling of session recording for device groups
511 }
512 if ((parent.parent.config.domains[domain.id].amtacmactivation != null) && (parent.parent.config.domains[domain.id].amtacmactivation.acmmatch != null)) {
@@ -1937,14 +1938,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1938 if ((ugroupidsplit.length != 3) || (ugroupidsplit[0] != 'ugrp') || (ugroupidsplit[1] != domain.id)) break;
1939
1940 // Get the user group
1941 + change = '';
1942 var group = parent.userGroups[command.ugrpid];
1943 if (group != null) {
1944 if ((common.validateString(command.name, 1, 64) == true) && (command.name != group.name)) { change = 'User group name changed from "' + group.name + '" to "' + command.name + '"'; group.name = command.name; }
1945 if ((common.validateString(command.desc, 0, 1024) == true) && (command.desc != group.desc)) { if (change != '') change += ' and description changed'; else change += 'User group "' + group.name + '" description changed'; group.desc = command.desc; }
1946 if ((typeof command.consent == 'number') && (command.consent != group.consent)) { if (change != '') change += ' and consent changed'; else change += 'User group "' + group.name + '" consent changed'; group.consent = command.consent; }
1947 +
1948 + if ((command.flags != null) && (typeof command.flags == 'number')) {
1949 + // Flags: 2 = Session Recording
1950 + if ((command.flags == 0) && (group.flags != null)) { delete group.flags; } else { if (command.flags !== group.flags) { group.flags = command.flags; } }
1951 + if (change == '') { change = 'User group flags changed.'; }
1952 + }
1953 +
1954 if (change != '') {
1955 db.Set(group);
1947 - var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, consent: ((group.consent == null) ? 0 : group.consent), action: 'usergroupchange', links: group.links, msg: change, domain: domain.id };
1956 + var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, consent: ((group.consent == null) ? 0 : group.consent), action: 'usergroupchange', links: group.links, flags: group.flags, msg: change, domain: domain.id };
1957 if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
1958 parent.parent.DispatchEvent(['*', group._id, user._id], obj, event);
1959 }
sample-config-advanced.json
+1
@@ -313,6 +313,7 @@
313 "_agentConfig": [ "webSocketMaskOverride=1", "coreDumpEnabled=1" ],
314 "_sessionRecording": {
315 "_onlySelectedUsers": true,
316 + "_onlySelectedUserGroups": true,
317 "_onlySelectedDeviceGroups": true,
318 "_filepath": "C:\\temp",
319 "_index": true,
views/default-mobile.handlebars
+1
@@ -1743,6 +1743,7 @@
1743 ugroup.name = message.event.name;
1744 ugroup.desc = message.event.desc;
1745 ugroup.links = message.event.links;
1746 + ugroup.flags = message.event.flags;
1747 }
1748 //mainUpdate(8192 + 16384);
1749
views/default.handlebars
+28 -1
@@ -2935,6 +2935,7 @@
2935 ugroup.name = message.event.name;
2936 if (message.event.desc) { ugroup.desc = message.event.desc; } else { delete ugroup.desc; }
2937 if (message.event.links) { ugroup.links = message.event.links; } else { delete ugroup.links; }
2938 + if (message.event.flags) { ugroup.flags = message.event.flags; } else { delete ugroup.flags; }
2939 if (typeof message.event.consent == 'number') { ugroup.consent = message.event.consent; }
2940 }
2941 mainUpdate(4096 + 8192 + 16384);
@@ -12928,7 +12929,7 @@
12929
12930 var msg;
12931 if ((event.msgid == null) || (eventsMessageId[event.msgid] == null)) {
12931 - msg = EscapeHtml(event.msg).split('(R)').join('®');
12932 + if (typeof event.msg == 'string') { msg = EscapeHtml(event.msg).split('(R)').join('®'); } else { msg = ''; }
12933 } else {
12934 msg = eventsMessageId[event.msgid];
12935 if (event.msgArgs != null) {
@@ -13828,6 +13829,15 @@
13829 x += addDeviceAttribute("Description", desc);
13830 }
13831
13832 + // Display features
13833 + if (serverinfo.userGroupsSessionRecording == 1) {
13834 + var userGroupFeatures = [];
13835 + if ((group.flags) && (group.flags & 2)) { userGroupFeatures.push("Record Sessions"); }
13836 + userGroupFeatures = userGroupFeatures.join(', ');
13837 + if (userGroupFeatures == '') { userGroupFeatures = '<i>' + "None" + '</i>'; }
13838 + x += addDeviceAttribute("Features", addLink(userGroupFeatures, 'p51edituserGroupFeatures()'));
13839 + }
13840 +
13841 // Display user consent flags for this user group
13842 {
13843 var consentOptionsStr = [], consent = 0;
@@ -13951,6 +13961,23 @@
13961 }
13962 }
13963
13964 + function p51edituserGroupFeatures() {
13965 + if (xxdialogMode) return;
13966 + var flags = (currentUserGroup.flags)?currentUserGroup.flags:0, x = ''; // Flags: 2 = Session Recording
13967 + if (serverinfo.userGroupsSessionRecording == 1) {
13968 + x += '<div><label><input type=checkbox id=d51flag1 ' + ((flags & 2) ? 'checked' : '') + '>' + "Record sessions" + '</label><br></div>';
13969 + }
13970 + setDialogMode(2, "Edit User Group Features", 3, p51edituserGroupFeaturesEx, x);
13971 + }
13972 +
13973 + // Send to the server the new user's real name
13974 + function p51edituserGroupFeaturesEx() {
13975 + // Setup user flags
13976 + var f = 0;
13977 + if ((serverinfo.userGroupsSessionRecording == 1) && Q('d51flag1').checked) { f += 2; }
13978 + meshserver.send({ action: 'editusergroup', ugrpid: currentUserGroup._id, flags: f });
13979 + }
13980 +
13981 function p51removeDeviceFromUserGroup(e, nodeid) {
13982 if (xxdialogMode) return;
13983 var node = getNodeFromId(decodeURIComponent(nodeid));