Add authentication to socket.io server

Authenticate connections made to the socket.io server via a token query
parameter that's validated in a similar manner to the x-access-token for
HTTP requests.
This commit is contained in:
Hornwitser committed 2019-09-10 23:51:48 +02:00
1 parent 88eff17dfd
commit 0c45e57732
3 files changed
+25 -1

No files matched your search

+4 -1
View File
@@ -570,7 +570,10 @@ async function instanceManagement(instanceconfig) {
console.log("Started instanceManagement();");
/* Open websocket connection to master */
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort);
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort+"?token="+config.masterAuthToken);
socket.on("error", err => {
console.log("SOCKET | Error: ", err);
});
socket.on("hello", data => {
console.log("SOCKET | registering slave!");
socket.emit("registerSlave", {