Added Intel AMT WIFI to config.json schema.

Ylian Saint-Hilaire committed Oct 22, 2020 at 19:51 UTC cc652d8e33d117abe2df3140d0e444bac4630e1f
3 files changed +47 -10
amtmanager.js
+2 -2
@@ -77,13 +77,13 @@ module.exports.CreateAmtManager = function (parent) {
77 if (typeof wifiProfile.authentication == 'string') { wifiProfile.authentication = wifiProfile.authentication.toLowerCase(); }
78 if (wifiProfile.authentication == 'wpa-psk') { wifiProfile.authentication = 4; }
79 if (wifiProfile.authentication == 'wpa2-psk') { wifiProfile.authentication = 6; }
80 - if (typeof wifiProfile.authentication != 'number') { wifiProfile.authentication = 4; } // Default to CCMP-AES
80 + if (typeof wifiProfile.authentication != 'number') { wifiProfile.authentication = 6; } // Default to WPA2-PSK
81
82 // Encyption
83 if (typeof wifiProfile.encryption == 'string') { wifiProfile.encryption = wifiProfile.encryption.toLowerCase(); }
84 if ((wifiProfile.encryption == 'ccmp-aes') || (wifiProfile.encryption == 'ccmp')) { wifiProfile.encryption = 4; }
85 if ((wifiProfile.encryption == 'tkip-rc4') || (wifiProfile.encryption == 'tkip')) { wifiProfile.encryption = 3; }
86 - if (typeof wifiProfile.encryption != 'number') { wifiProfile.encryption = 6; } // Default to WPA2-PSK
86 + if (typeof wifiProfile.encryption != 'number') { wifiProfile.encryption = 4; } // Default to CCMP-AES
87
88 // Type
89 wifiProfile.type = 3; // Infrastructure
meshcentral-config-schema.json
+37
@@ -305,6 +305,43 @@
305 "maxItems": 4,
306 "uniqueItems": true
307 }
308 + },
309 + "WifiProfiles": {
310 + "description": "List of WIFI profiles to setup in any managed Intel AMT device with a WIFI network interface.",
311 + "type": "array",
312 + "items": {
313 + "type": "object",
314 + "additionalProperties": false,
315 + "required": [ "ssid", "password" ],
316 + "properties": {
317 + "name": {
318 + "description": "WIFI profile name, if not specified the SSID is used.",
319 + "type": "string"
320 + },
321 + "ssid": {
322 + "description": "SSID of the WIFI station.",
323 + "type": "string"
324 + },
325 + "authentication": {
326 + "description": "WIFI authentication.",
327 + "type": "string",
328 + "enum": [ "wpa2-psk", "wpa-psk" ],
329 + "default": "wpa2-psk"
330 + },
331 + "encryption": {
332 + "description": "WIFI encryption.",
333 + "type": "string",
334 + "enum": [ "ccmp-aes", "tkip-rc4" ],
335 + "default": "ccmp-aes"
336 + },
337 + "password": {
338 + "description": "Password on the WIFI station",
339 + "type": "string",
340 + "minLength": 8,
341 + "maxLength": 63
342 + }
343 + }
344 + }
345 }
346 }
347 },
mqttbroker.js
+8 -8
@@ -31,16 +31,16 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
31
32 // Connection Authentication
33 aedes.authenticate = function (client, username, password, callback) {
34 - obj.parent.debug("mqtt", "Authentication User:" + username + ", Pass:" + password.toString() + ", ClientID:" + client.id + ", " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip));
34 + obj.parent.debug('mqtt', "Authentication User:" + username + ", Pass:" + password.toString() + ", ClientID:" + client.id + ", " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip));
35
36 // Parse the username and password
37 var usersplit = username.split(':');
38 var passsplit = password.toString().split(':');
39 - if ((usersplit.length !== 4) || (passsplit.length !== 3)) { obj.parent.debug("mqtt", "Invalid user/pass format, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
40 - if (usersplit[0] !== 'MCAuth1') { obj.parent.debug("mqtt", "Invalid auth method, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
39 + if ((usersplit.length !== 4) || (passsplit.length !== 3)) { obj.parent.debug('mqtt', "Invalid user/pass format, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
40 + if (usersplit[0] !== 'MCAuth1') { obj.parent.debug('mqtt', "Invalid auth method, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
41
42 // Check authentication
43 - if (passsplit[0] !== parent.config.settings.mqtt.auth.keyid) { obj.parent.debug("mqtt", "Invalid auth keyid, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
43 + if (passsplit[0] !== parent.config.settings.mqtt.auth.keyid) { obj.parent.debug('mqtt', "Invalid auth keyid, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
44 if (parent.crypto.createHash('sha384').update(username + ':' + passsplit[1] + ':' + parent.config.settings.mqtt.auth.key).digest("base64") !== passsplit[2]) { obj.parent.debug("mqtt", "Invalid password, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(authError, null); return; }
45
46 // Setup the identifiers
@@ -49,7 +49,7 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
49 const xdomainid = usersplit[3];
50
51 // Check the domain
52 - if ((typeof client.conn.xdomain == 'object') && (xdomainid != client.conn.xdomain.id)) { obj.parent.debug("mqtt", "Invalid domain connection, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(null, false); return; }
52 + if ((typeof client.conn.xdomain == 'object') && (xdomainid != client.conn.xdomain.id)) { obj.parent.debug('mqtt', "Invalid domain connection, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip)); callback(null, false); return; }
53
54 // Convert meshid from HEX to Base64 if needed
55 if (xmeshid.length === 96) { xmeshid = Buffer.from(xmeshid, 'hex').toString('base64'); }
@@ -77,7 +77,7 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
77 client.conn.parent = client;
78 client.conn.on('end', function () {
79 // client is "this.parent"
80 - obj.parent.debug("mqtt", "Connection closed, " + this.parent.conn.xtransport + "://" + cleanRemoteAddr(this.parent.conn.xip));
80 + obj.parent.debug('mqtt', "Connection closed, " + this.parent.conn.xtransport + '://' + cleanRemoteAddr(this.parent.conn.xip));
81
82 // Remove this client from the connections list
83 if ((this.parent.xdbNodeKey != null) && (obj.connections[this.parent.xdbNodeKey] != null)) {
@@ -99,7 +99,7 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
99 // Check if a client can publish a packet
100 aedes.authorizeSubscribe = function (client, sub, callback) {
101 // Subscription control
102 - obj.parent.debug("mqtt", "AuthorizeSubscribe \"" + sub.topic + "\", " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip));
102 + obj.parent.debug('mqtt', "AuthorizeSubscribe \"" + sub.topic + '", ' + client.conn.xtransport + '://' + cleanRemoteAddr(client.conn.xip));
103 if (allowedSubscriptionTopics.indexOf(sub.topic) === -1) { sub = null; } // If not a supported subscription, deny it.
104 callback(null, sub); // We authorize supported topics, but will not allow agents to publish anything to other agents.
105 }
@@ -107,7 +107,7 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
107 // Check if a client can publish a packet
108 aedes.authorizePublish = function (client, packet, callback) {
109 // Handle a published message
110 - obj.parent.debug("mqtt", "AuthorizePublish, " + client.conn.xtransport + "://" + cleanRemoteAddr(client.conn.xip));
110 + obj.parent.debug('mqtt', "AuthorizePublish, " + client.conn.xtransport + '://' + cleanRemoteAddr(client.conn.xip));
111 handleMessage(client.xdbNodeKey, client.xdbMeshKey, client.xdomainid, packet.topic, packet.payload);
112 // We don't accept that any client message be published, so don't call the callback.
113 }