Web app changes depending on AMT manager running.
Ylian Saint-Hilaire committed
Oct 23, 2020 at 10:11 UTC
b36b0c81515cdbd1a8af0cbb918150ef5b66bc3a
3 files changed
+28
-17
meshuser.js
+2
-1
@@ -3847,7 +3847,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3847
if (command.desc != null && (command.desc != node.desc)) { change = 1; node.desc = command.desc; changes.push('description'); }
3848
if (command.intelamt != null) {
3849
if ((command.intelamt.user != null) && (command.intelamt.pass != undefined) && ((command.intelamt.user != node.intelamt.user) || (command.intelamt.pass != node.intelamt.pass))) { change = 1; node.intelamt.user = command.intelamt.user; node.intelamt.pass = command.intelamt.pass; changes.push('Intel AMT credentials'); amtchange = 1; }
3850
- if ((command.intelamt.tls != null) && (command.intelamt.tls != node.intelamt.tls)) { change = 1; node.intelamt.tls = command.intelamt.tls; changes.push('Intel AMT TLS'); }
3850
+ // Only allow the user to set Intel AMT TLS state if AMT Manager is not active. AMT manager will auto-detect TLS state.
3851
+ if ((parent.parent.amtManager != null) && (command.intelamt.tls != null) && (command.intelamt.tls != node.intelamt.tls)) { change = 1; node.intelamt.tls = command.intelamt.tls; changes.push('Intel AMT TLS'); }
3852
}
3853
if (command.tags) { // Node grouping tag, this is a array of strings that can't be empty and can't contain a comma
3854
var ok = true, group2 = [];
views/default.handlebars
+22
-15
@@ -1263,6 +1263,7 @@
1263
var files;
1264
var debugLevel = parseInt('{{{debuglevel}}}');
1265
var features = parseInt('{{{features}}}');
1266
+ var features2 = parseInt('{{{features2}}}');
1267
var sessionTime = parseInt('{{{sessiontime}}}');
1268
var sessionRefreshTimer = null;
1269
var domain = '{{{domain}}}';
@@ -6222,11 +6223,12 @@
6223
if ((meshrights & 4) == 0) return;
6224
x += addHtmlValue("Username", '<input id=dp10username style=width:230px maxlength=32 autocomplete=nope placeholder="admin" onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');
6225
x += addHtmlValue("Password", '<input id=dp10password type=password style=width:230px autocomplete=nope maxlength=32 onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');
6225
- x += addHtmlValue("Security", '<select id=dp10tls style=width:236px><option value=0>' + "No TLS security" + '</option><option value=1>' + "TLS security required" + '</option></select>');
6226
+ // Only display the TLS setting if the Intel AMT manager is not running on the server. With the manager TLS is auto-detected.
6227
+ if ((features2 & 1) == 0) { x += addHtmlValue("Security", '<select id=dp10tls style=width:236px><option value=0>' + "No TLS security" + '</option><option value=1>' + "TLS security required" + '</option></select>'); }
6228
if ((node.intelamt.user != null) && (node.intelamt.user != '')) { buttons = 7; }
6229
setDialogMode(2, "Edit Intel® AMT credentials", buttons, editDeviceAmtSettingsEx, x, { node: node, func: func, arg: arg });
6230
if ((node.intelamt.user != null) && (node.intelamt.user != '')) { Q('dp10username').value = node.intelamt.user; } else { Q('dp10username').value = 'admin'; }
6229
- Q('dp10tls').value = node.intelamt.tls;
6231
+ if ((features2 & 1) == 0) { Q('dp10tls').value = node.intelamt.tls; }
6232
validateDeviceAmtSettings();
6233
}
6234
@@ -6244,9 +6246,11 @@
6246
if (amtuser == '') amtuser = 'admin';
6247
var amtpass = Q('dp10password').value;
6248
if (amtpass == '') amtuser = '';
6247
- meshserver.send({ action: 'changedevice', nodeid: tag.node._id, intelamt: { user: amtuser, pass: amtpass, tls: parseInt(Q('dp10tls').value) } });
6249
+ var x = { action: 'changedevice', nodeid: tag.node._id, intelamt: { user: amtuser, pass: amtpass } };
6250
+ if ((features2 & 1) == 0) { x.intelamt.tls = parseInt(Q('dp10tls').value); }
6251
+ meshserver.send(x);
6252
tag.node.intelamt.user = amtuser;
6249
- tag.node.intelamt.tls = parseInt(Q('dp10tls').value);
6253
+ if ((features2 & 1) == 0) { tag.node.intelamt.tls = parseInt(Q('dp10tls').value); }
6254
if (tag.func) { setTimeout(function () { tag.func(null, tag.arg); }, 300); }
6255
}
6256
}
@@ -9398,19 +9402,22 @@
9402
x += addHtmlValue("Invite Codes", addLinkConditional(inviteCodeStr, 'p20editmeshInviteCode()', (meshrights & 1) || (icodes)));
9403
}
9404
9401
- // Intel AMT setup
9402
- var intelAmtPolicy = "No Policy";
9403
- if (currentMesh.amt) {
9404
- if (currentMesh.amt.type == 1) { intelAmtPolicy = 'Deactivate Client Control Mode (CCM)'; }
9405
- else if (currentMesh.amt.type == 2) {
9406
- intelAmtPolicy = "Simple Client Control Mode (CCM)";
9407
- if (currentMesh.amt.cirasetup == 2) { intelAmtPolicy += " + CIRA"; }
9408
- } else if (currentMesh.amt.type == 3) {
9409
- intelAmtPolicy = "Simple Admin Control Mode (ACM)";
9410
- if (currentMesh.amt.cirasetup == 2) { intelAmtPolicy += " + CIRA"; }
9405
+ // If the Intel AMT manager is active on the server, show the Intel AMT policy edit box.
9406
+ if ((features2 & 1) != 0) {
9407
+ // Intel AMT setup
9408
+ var intelAmtPolicy = "No Policy";
9409
+ if (currentMesh.amt) {
9410
+ if (currentMesh.amt.type == 1) { intelAmtPolicy = 'Deactivate Client Control Mode (CCM)'; }
9411
+ else if (currentMesh.amt.type == 2) {
9412
+ intelAmtPolicy = "Simple Client Control Mode (CCM)";
9413
+ if (currentMesh.amt.cirasetup == 2) { intelAmtPolicy += " + CIRA"; }
9414
+ } else if (currentMesh.amt.type == 3) {
9415
+ intelAmtPolicy = "Simple Admin Control Mode (ACM)";
9416
+ if (currentMesh.amt.cirasetup == 2) { intelAmtPolicy += " + CIRA"; }
9417
+ }
9418
}
9419
+ x += addHtmlValue("Intel® AMT", addLinkConditional(intelAmtPolicy, 'p20editMeshAmt()', meshrights & 1));
9420
}
9413
- x += addHtmlValue("Intel® AMT", addLinkConditional(intelAmtPolicy, 'p20editMeshAmt()', meshrights & 1));
9421
9422
// Display group note support
9423
if (meshrights & 1) { x += '<br><input type=button value=' + "Notes" + ' title="' + "View notes about this device group" + '" onclick=showNotes(false,"' + encodeURIComponentEx(currentMesh._id) + '") />'; }
webserver.js
+4
-1
@@ -2123,7 +2123,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2123
}
2124
2125
function handleRootRequestEx(req, res, domain, direct) {
2126
- var nologout = false, user = null, features = 0;
2126
+ var nologout = false, user = null, features = 0, features2 = 0;
2127
res.set({ 'Cache-Control': 'no-store' });
2128
2129
// Check if we have an incomplete domain name in the path
@@ -2285,6 +2285,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2285
2286
// Give the web page a list of supported server features
2287
features = 0;
2288
+ features2 = 0;
2289
if (obj.args.wanonly == true) { features += 0x00000001; } // WAN-only mode
2290
if (obj.args.lanonly == true) { features += 0x00000002; } // LAN-only mode
2291
if (obj.args.nousers == true) { features += 0x00000004; } // Single user mode
@@ -2326,6 +2327,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2327
if (domain.novnc === false) { features += 0x20000000; } // Disables noVNC
2328
if (domain.mstsc !== true) { features += 0x40000000; } // Disables MSTSC.js
2329
if (obj.isTrustedCert(domain) == false) { features += 0x80000000; } // Indicate we are not using a trusted certificate
2330
+ if (obj.parent.amtManager != null) { features2 += 1; } // Indicates that the Intel AMT manager is active
2331
2332
// Create a authentication cookie
2333
const authCookie = obj.parent.encodeCookie({ userid: user._id, domainid: domain.id, ip: req.clientIp }, obj.parent.loginCookieEncryptionKey);
@@ -2390,6 +2392,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2392
serverPublicPort: httpsPort,
2393
serverfeatures: serverFeatures,
2394
features: features,
2395
+ features2: features2,
2396
sessiontime: args.sessiontime,
2397
mpspass: args.mpspass,
2398
passRequirements: passRequirements,