Added user consent option on desktop connect button.

This commit is contained in:
Ylian Saint-Hilaire 2020-04-14 19:12:14 -07:00
parent d71271f89d
commit 3f666107d0
3 changed files with 31 additions and 10 deletions

View File

@ -795,7 +795,7 @@ function createMeshCore(agent) {
if (process.platform != 'win32') break; if (process.platform != 'win32') break;
var p = require('user-sessions').enumerateUsers(); var p = require('user-sessions').enumerateUsers();
p.sessionid = data.sessionid; p.sessionid = data.sessionid;
p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u }); }); p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u, tag: data.tag }); });
break; break;
} }
default: default:
@ -1804,6 +1804,10 @@ function createMeshCore(agent) {
//sendConsoleText('options: ' + JSON.stringify(obj)); //sendConsoleText('options: ' + JSON.stringify(obj));
delete obj.type; delete obj.type;
ws.httprequest.xoptions = obj; ws.httprequest.xoptions = obj;
// Set additional user consent options if present
if ((obj != null) && (typeof obj.consent == 'number')) { ws.httprequest.consent += obj.consent; }
break; break;
} }
case 'close': { case 'close': {

View File

@ -3482,7 +3482,7 @@
// Check device group link permission // Check device group link permission
var rights = 0, r = mesh.links[userid]; var rights = 0, r = mesh.links[userid];
if (r != null) { if (r != null) {
if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
rights = r.rights; rights = r.rights;
} }

View File

@ -69,6 +69,9 @@
<div id="cxtermps" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div> <div id="cxtermps" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
<div id="cxtermps" class="cmtext" onclick="cmtermaction(100,event)">Login Shell</div> <div id="cxtermps" class="cmtext" onclick="cmtermaction(100,event)">Login Shell</div>
</div> </div>
<div id="deskConnectContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
<div id="cxdeskuc" class="cmtext" onclick="cmdeskaction(1,event)"><b>Ask Consent</b></div>
</div>
<div id="altPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px"> <div id="altPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
<div id="cxaltport" class="cmtext" onclick="cmaltportaction(1,event)"><b>Alternate Port</b></div> <div id="cxaltport" class="cmtext" onclick="cmaltportaction(1,event)"><b>Alternate Port</b></div>
</div> </div>
@ -511,7 +514,7 @@
<div> <div>
<div id="idx_deskFullBtn2" onclick=deskToggleFull(event)>&nbsp;&#x2716;</div> <div id="idx_deskFullBtn2" onclick=deskToggleFull(event)>&nbsp;&#x2716;</div>
<input type="button" id="autoconnectbutton1" value="AutoConnect" onclick=autoConnectDesktop(event) onkeypress="return false" onkeydown="return false" style="display:none" /> <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick=autoConnectDesktop(event) onkeypress="return false" onkeydown="return false" style="display:none" />
<span id=connectbutton1span><input type=button id=connectbutton1 value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span> <span id=connectbutton1span><input type=button id=connectbutton1 cmenu="deskConnectButton" value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
<span id=connectbutton1hspan>&nbsp;<input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span> <span id=connectbutton1hspan>&nbsp;<input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
<span id=disconnectbutton1span>&nbsp;<input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span> <span id=disconnectbutton1span>&nbsp;<input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span>
&nbsp;<span id="deskstatus">Disconnected</span> &nbsp;<span id="deskstatus">Disconnected</span>
@ -1902,12 +1905,12 @@
// Got list of user sessions // Got list of user sessions
var userSessions = []; var userSessions = [];
if (message.data != null) { for (var i in message.data) { if ((message.data[i].State == 'Active') || (message.data[i].StationName == 'Console') || (debugmode == 3)) { userSessions.push(message.data[i]); } } } if (message.data != null) { for (var i in message.data) { if ((message.data[i].State == 'Active') || (message.data[i].StationName == 'Console') || (debugmode == 3)) { userSessions.push(message.data[i]); } } }
if (userSessions.length == 0) { connectDesktop(null, 1); } // No active sessions, do a normal connection. if (userSessions.length == 0) { connectDesktop(null, 1, null, message.tag); } // No active sessions, do a normal connection.
else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId); } // One active session, connect to it else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId, message.tag); } // One active session, connect to it
else { else {
var x = ''; var x = '';
for (var i in userSessions) { for (var i in userSessions) {
x += '<div style="text-align:left;cursor:pointer;background-color:gray;margin:5px;padding:5px;border-radius:5px" onclick=connectDesktop(event,1,' + userSessions[i].SessionId + ')>' + userSessions[i].State + ', ' + userSessions[i].StationName; x += '<div style="text-align:left;cursor:pointer;background-color:gray;margin:5px;padding:5px;border-radius:5px" onclick=connectDesktop(event,1,' + userSessions[i].SessionId + ',' + message.tag + ')>' + userSessions[i].State + ', ' + userSessions[i].StationName;
if (userSessions[i].Username) { if (userSessions[i].Domain) { x += ' - ' + userSessions[i].Domain + '/' + userSessions[i].Username; } else { x += ' - ' + userSessions[i].Username; } } if (userSessions[i].Username) { if (userSessions[i].Domain) { x += ' - ' + userSessions[i].Domain + '/' + userSessions[i].Username; } else { x += ' - ' + userSessions[i].Username; } }
x += '</div>'; x += '</div>';
} }
@ -4004,6 +4007,13 @@
showContextMenuDiv(contextmenudiv, event.pageX, event.pageY); showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
break; break;
} }
case 'deskConnectButton': {
// Desktop connect button context menu
if ((currentNode == null) || (currentNode.agent == null)) return true;
contextelement = elem;
showContextMenuDiv(document.getElementById('deskConnectContextMenu'), event.pageX, event.pageY);
break;
}
case 'devsContentMenu': { case 'devsContentMenu': {
// Device content menu // Device content menu
contextelement = elem; contextelement = elem;
@ -4094,6 +4104,10 @@
} }
} }
function cmdeskaction(action) {
if (action == 1) { connectDesktop(null, 3, null, 0x0008); } // Do remote desktop connection using consent prompt
}
function cmaltportaction(action) { function cmaltportaction(action) {
if (xxdialogMode) return; if (xxdialogMode) return;
var x = "RDP remote connection port:" + '<br /><br /><input type=text placeholder="3389" inputmode="numeric" pattern="[0-9]*" onkeypress=\"return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)\" maxlength=5 id=d10rdpport type=text>'; var x = "RDP remote connection port:" + '<br /><br /><input type=text placeholder="3389" inputmode="numeric" pattern="[0-9]*" onkeypress=\"return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)\" maxlength=5 id=d10rdpport type=text>';
@ -4147,6 +4161,7 @@
QV('meshContextMenu', false); QV('meshContextMenu', false);
QV('termShellContextMenu', false); QV('termShellContextMenu', false);
QV('termShellContextMenuLinux', false); QV('termShellContextMenuLinux', false);
QV('deskConnectContextMenu', false);
QV('altPortContextMenu', false); QV('altPortContextMenu', false);
QV('filesContextMenu', false); QV('filesContextMenu', false);
//QV('pluginTabContextMenu', false); //QV('pluginTabContextMenu', false);
@ -5748,7 +5763,7 @@
var autoConnectDesktopTimer = null; var autoConnectDesktopTimer = null;
function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(function() { connectDesktop(null, 1) }, 1000); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } } function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(function() { connectDesktop(null, 1) }, 1000); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
function connectDesktop(e, contype, tsid) { function connectDesktop(e, contype, tsid, consent) {
if (xxdialogMode) return; if (xxdialogMode) return;
if ((e != null) && (e.shiftKey != false) && (contype == 3)) { contype = 1; } // If the shift key is not pressed, don't try to ask for session list. if ((e != null) && (e.shiftKey != false) && (contype == 3)) { contype = 1; } // If the shift key is not pressed, don't try to ask for session list.
QV('p11DeskSessionSelector', false); QV('p11DeskSessionSelector', false);
@ -5845,7 +5860,9 @@
desktop.debugmode = debugmode; desktop.debugmode = debugmode;
desktop.m.debugmode = debugmode; desktop.m.debugmode = debugmode;
desktop.attemptWebRTC = attemptWebRTC; desktop.attemptWebRTC = attemptWebRTC;
if (tsid != null) { desktop.options = { tsid: tsid }; } desktop.options = {};
if (tsid != null) { desktop.options.tsid = tsid; }
if (consent != null) { desktop.options.consent = consent; }
desktop.onStateChanged = onDesktopStateChange; desktop.onStateChanged = onDesktopStateChange;
desktop.onConsoleMessageChange = function () { desktop.onConsoleMessageChange = function () {
p11clearConsoleMsg(); p11clearConsoleMsg();
@ -5865,7 +5882,7 @@
desktop.contype = 1; desktop.contype = 1;
} else if (contype == 3) { } else if (contype == 3) {
// Ask for user sessions // Ask for user sessions
meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id }); meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent });
} }
} else { } else {
// Disconnect and clean up the remote desktop // Disconnect and clean up the remote desktop
@ -11725,7 +11742,7 @@
// Check device group link permission // Check device group link permission
var rights = 0, r = mesh.links[userid]; var rights = 0, r = mesh.links[userid];
if (r != null) { if (r != null) {
if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
rights = r.rights; rights = r.rights;
} }