Skip to content

Commit

Permalink
Improved MeshCMD server authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Apr 6, 2021
1 parent eb9b9d7 commit b9b2aa5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
Binary file modified agents/MeshCmd-signed.exe
Binary file not shown.
Binary file modified agents/MeshCmd64-signed.exe
Binary file not shown.
7 changes: 6 additions & 1 deletion agents/meshcmd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion meshcentral.js
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ function mainStart() {
if (passport != null) { modules.push(...passport); }
if (sessionRecording == true) { modules.push('image-size'); } // Need to get the remote desktop JPEG sizes to index the recodring file.
if (config.letsencrypt != null) { if (nodeVersion < 8) { addServerWarning("Let's Encrypt support requires Node v8.x or higher.", !args.launch); } else { modules.push('acme-client'); } } // Add acme-client module
if (config.settings.mqtt != null) { modules.push('aedes'); } // Add MQTT Modules
if (config.settings.mqtt != null) { modules.push('aedes@0.39.0'); } // Add MQTT Modules
if (config.settings.mysql != null) { modules.push('mysql'); } // Add MySQL.
//if (config.settings.mysql != null) { modules.push('@mysql/xdevapi'); } // Add MySQL, official driver (https://dev.mysql.com/doc/dev/connector-nodejs/8.0/)
if (config.settings.mongodb != null) { modules.push('mongodb'); modules.push('saslprep'); } // Add MongoDB, official driver.
Expand Down
4 changes: 3 additions & 1 deletion meshuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5146,7 +5146,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Get the node and the rights for this node
parent.GetNodeWithRights(domain, user, command.nodeids[i], function (node, rights, visible) {
// If this device is connected on MQTT, send a wake action.
if (rights != 0) { parent.parent.mqttbroker.publish(node._id, command.topic, command.msg); }
if (rights != 0) {
parent.parent.mqttbroker.publish(node._id, command.topic, command.msg);
}
});
}

Expand Down
8 changes: 5 additions & 3 deletions mqttbroker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
obj.db = db;
obj.args = args;
obj.connections = {}; // NodesID --> client array
const aedes = require("aedes")();
const aedes = require('aedes')();
obj.handle = aedes.handle;
const allowedSubscriptionTopics = [ 'presence' ];
const allowedSubscriptionTopics = ['presence', 'console', 'powerAction'];
const denyError = new Error('denied');
var authError = new Error('Auth error')
authError.returnCode = 1
Expand Down Expand Up @@ -127,7 +127,9 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
if (typeof message == 'string') { message = Buffer.from(message); }
for (var i in clients) {
// Only publish to client that subscribe to the topic
if (clients[i].subscriptions[topic] != null) { clients[i].publish({ cmd: 'publish', qos: 0, topic: topic, payload: message, retain: false }); }
if (clients[i].subscriptions[topic] != null) {
clients[i].publish({ cmd: 'publish', qos: 0, topic: topic, payload: message, retain: false }, function () { });
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"sample-config-advanced.json"
],
"dependencies": {
"aedes": "^0.45.0",
"archiver": "^4.0.2",
"archiver-zip-encrypted": "^1.0.8",
"body-parser": "^1.19.0",
"cbor": "~5.2.0",
"compression": "^1.7.4",
Expand All @@ -44,14 +47,23 @@
"express": "^4.17.0",
"express-handlebars": "^3.1.0",
"express-ws": "^4.0.0",
"image-size": "^0.9.7",
"ipcheck": "^0.1.0",
"loadavg-windows": "^1.1.1",
"minimist": "^1.2.0",
"mongodb": "^3.6.5",
"multiparty": "^4.2.1",
"nedb": "^1.8.0",
"node-forge": "^0.10.0",
"node-rdpjs-2": "^0.3.5",
"node-windows": "^1.0.0-beta.5",
"otplib": "^10.2.3",
"saslprep": "^1.0.3",
"web-push": "^3.4.4",
"ws": "^6.2.1",
"xmldom": "^0.5.0",
"yauzl": "^2.10.0"
"yauzl": "^2.10.0",
"yubikeyotp": "^0.2.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit b9b2aa5

Please sign in to comment.