Added device group permissions.
Ylian Saint-Hilaire committed
Feb 26, 2019 at 17:08 UTC
a5cb7e74e0ae8c935fa56684504de2efbb3ea958
2 files changed
+44
-22
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.2.9-e",
3
+ "version": "0.2.9-h",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
views/default.handlebars
+43
-21
@@ -2730,9 +2730,14 @@
2730
var meshlinks = mesh.links['user/' + domain + '/' + userinfo.name.toLowerCase()];
2731
var meshrights = meshlinks.rights;
2732
var consoleRights = ((meshrights & 16) != 0);
2733
+
2734
+ // Check if we have terminal and file access
2735
+ var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
2736
+ var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
2737
+
2738
QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
2734
- QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8));
2735
- QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8));
2739
+ QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
2740
+ QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
2741
QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8));
2742
QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
2743
@@ -3575,9 +3580,14 @@
3580
Q('MainComputerImage').setAttribute("src", "images/icons200-" + node.icon + "-1.jpg");
3581
Q('MainComputerImage').className = ((!node.conn) || (node.conn == 0)?'gray':'');
3582
3583
+ // Check if we have terminal and file access
3584
+ var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
3585
+ var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
3586
+ var amtAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 2048) == 0));
3587
+
3588
// Setup/Refresh the desktop tab
3579
- setupTerminal();
3580
- setupFiles();
3589
+ if (terminalAccess) { setupTerminal(); }
3590
+ if (fileAccess) { setupFiles(); }
3591
var consoleRights = ((meshrights & 16) != 0);
3592
if (consoleRights) { setupConsole(); } else { if (panel == 15) { panel = 10; } }
3593
@@ -3585,9 +3595,9 @@
3595
// mesh.mtype: 1 = Intel AMT only, 2 = Mesh Agent
3596
// node.agent.caps (bitmask): 1 = Desktop, 2 = Terminal, 4 = Files, 8 = Console
3597
QV('MainDevDesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
3588
- QV('MainDevTerminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8));
3589
- QV('MainDevFiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8));
3590
- QV('MainDevAmt', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8));
3598
+ QV('MainDevTerminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
3599
+ QV('MainDevFiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
3600
+ QV('MainDevAmt', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8) && amtAccess);
3601
QV('MainDevConsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
3602
QV('p15uploadCore', (node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 16) != 0));
3603
QH('p15coreName', ((node.agent != null) && (node.agent.core != null))?node.agent.core:'');
@@ -5813,7 +5823,7 @@
5823
var trash = '', rights = 'Partial Rights', r = sortedusers[i].rights;
5824
if (r == 0xFFFFFFFF) rights = 'Full Administrator'; else if (r == 0) rights = 'No Rights';
5825
if ((i != userinfo._id) && (meshrights == 0xFFFFFFFF || (((meshrights & 2) != 0)))) { trash = '<a onclick=p20deleteUser(event,"' + encodeURIComponent(sortedusers[i].id) + '") title="Remote user rights to this mesh" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'; }
5816
- x += '<tr onclick=p20viewuser("' + encodeURIComponent(sortedusers[i].id) + '") style=cursor:pointer' + (((count % 2) == 0)?';background-color:#DDD':'') + '><td><div title="User" class=m2></div><div> ' + sortedusers[i].name + '<div></div></div></td><td><div style=float:right>' + trash + '</div><div>' + rights + '</div></td></tr>';
5826
+ x += '<tr onclick=p20viewuser("' + encodeURIComponent(sortedusers[i].id) + '") style=cursor:pointer' + (((count % 2) == 0) ? ';background-color:#DDD' : '') + '><td><div title="User" class=m2></div><div> ' + EscapeHtml(decodeURIComponent(sortedusers[i].name)) + '<div></div></div></td><td><div style=float:right>' + trash + '</div><div>' + rights + '</div></td></tr>';
5827
++count;
5828
}
5829
@@ -5921,17 +5931,20 @@
5931
if (xxdialogMode) return;
5932
var x = "Allow a user to manage this device group and devices in this group<br /><br />";
5933
x += addHtmlValue('User Name', '<input id=dp20username style=width:230px maxlength=32 onchange=p20validateAddMeshUserDialog() onkeyup=p20validateAddMeshUserDialog() />');
5924
- x += '<br><div>';
5934
+ x += '<br><div style="height:120px;overflow-y:scroll;border:1px solid gray">';
5935
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20fulladmin>Full Administrator<br>';
5936
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editmesh>Edit Device Group<br>';
5937
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20manageusers>Manage Device Group Users<br>';
5938
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20managecomputers>Manage Device Group Computers<br>';
5939
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotecontrol>Remote Control<br>';
5940
+ x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remoteview style=margin-left:12px>Remote View Only<br>';
5941
+ x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noterminal style=margin-left:12px>No Terminal Access<br>';
5942
+ x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20nofiles style=margin-left:12px>No File Access<br>';
5943
+ x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noamt style=margin-left:12px>No Intel® AMT<br>';
5944
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshagentconsole>Mesh Agent Console<br>';
5945
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshserverfiles>Server Files<br>';
5946
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20wakedevices>Wake Devices<br>';
5947
x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>Edit Device Notes<br>';
5934
- x += '<input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remoteview>Remote View Only<br>';
5948
x += '</div>';
5949
setDialogMode(2, "Add User to Device Group", 3, p20showAddMeshUserDialogEx, x);
5950
p20validateAddMeshUserDialog();
@@ -5950,7 +5963,10 @@
5963
QE('p20meshserverfiles', !Q('p20fulladmin').checked);
5964
QE('p20wakedevices', !Q('p20fulladmin').checked);
5965
QE('p20editnotes', !Q('p20fulladmin').checked);
5953
- QE('p20remoteview', !Q('p20fulladmin').checked);
5966
+ QE('p20remoteview', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked);
5967
+ QE('p20noterminal', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked);
5968
+ QE('p20nofiles', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked);
5969
+ QE('p20noamt', !Q('p20fulladmin').checked && Q('p20remotecontrol').checked);
5970
}
5971
5972
function p20showAddMeshUserDialogEx() {
@@ -5965,6 +5981,9 @@
5981
if (Q('p20wakedevices').checked == true) meshadmin += 64;
5982
if (Q('p20editnotes').checked == true) meshadmin += 128;
5983
if (Q('p20remoteview').checked == true) meshadmin += 256;
5984
+ if (Q('p20noterminal').checked == true) meshadmin += 512;
5985
+ if (Q('p20nofiles').checked == true) meshadmin += 1024;
5986
+ if (Q('p20noamt').checked == true) meshadmin += 2048;
5987
}
5988
meshserver.send({ action: 'addmeshuser', meshid: currentMesh._id, meshname: currentMesh.name, username: Q('dp20username').value , meshadmin: meshadmin});
5989
}
@@ -5974,19 +5993,22 @@
5993
userid = decodeURIComponent(userid);
5994
var r = '', cmeshrights = currentMesh.links['user/' + domain + '/' + userinfo.name.toLowerCase()].rights, meshrights = currentMesh.links[userid].rights;
5995
if (meshrights == 0xFFFFFFFF) r = ', Full Administrator (all rights)'; else {
5977
- if ((meshrights & 1) != 0) r += ', Edit Device Group';
5978
- if ((meshrights & 2) != 0) r += ', Manage Device Group Users';
5979
- if ((meshrights & 4) != 0) r += ', Manage Device Group Computers';
5980
- if ((meshrights & 8) != 0) r += ', Remote Control';
5981
- if ((meshrights & 16) != 0) r += ', Agent Console';
5982
- if ((meshrights & 32) != 0) r += ', Server Files';
5983
- if ((meshrights & 64) != 0) r += ', Wake Devices';
5984
- if ((meshrights & 128) != 0) r += ', Edit Notes';
5985
- if ((meshrights & 256) != 0) r += ', Remote View Only';
5996
+ if ((meshrights & 1) != 0) r += ', Edit Device Group';
5997
+ if ((meshrights & 2) != 0) r += ', Manage Device Group Users';
5998
+ if ((meshrights & 4) != 0) r += ', Manage Device Group Computers';
5999
+ if ((meshrights & 8) != 0) r += ', Remote Control';
6000
+ if ((meshrights & 16) != 0) r += ', Agent Console';
6001
+ if ((meshrights & 32) != 0) r += ', Server Files';
6002
+ if ((meshrights & 64) != 0) r += ', Wake Devices';
6003
+ if ((meshrights & 128) != 0) r += ', Edit Notes';
6004
+ if ((meshrights & 256) != 0) r += ', Remote View Only';
6005
+ if ((meshrights & 512) != 0) r += ', No Terminal';
6006
+ if ((meshrights & 1024) != 0) r += ', No Files';
6007
+ if ((meshrights & 2048) != 0) r += ', No Intel® AMT';
6008
}
6009
r = r.substring(2);
6010
if (r == '') { r = 'No Rights'; }
5989
- var buttons = 1, x = addHtmlValue('User Name', userid.split('/')[2]);
6011
+ var buttons = 1, x = addHtmlValue('User Name', EscapeHtml(decodeURIComponent(userid.split('/')[2])));
6012
x += addHtmlValue('Permissions', r);
6013
if ((('user/' + domain + '/' + userinfo.name.toLowerCase()) != userid) && (cmeshrights == 0xFFFFFFFF || (((cmeshrights & 2) != 0) && (meshrights != 0xFFFFFFFF)))) buttons += 4;
6014
setDialogMode(2, "Device Group User", buttons, p20viewuserEx, x, userid);