var ws = new WebSocketServer ({
port : port,
verifyClient: function(info, cb) {
if (info.req.headers.authorization == 'Basic Y2xpZW50OlN3b3JkZmlzaA==') {
cb(true);
} else {
cb(false);
}
}
});
Is this the solution contemplated by the book? Or the challenge expected a connection to be established then a ‘password’ string to be evaluated then allow the client to access all the messages already sent and the new messages?
To connect to the ws-server I would use the command: wscat -c ws://client:Swordfish@localhost:3001
that would add an Authorization header to the http request. Y2xpZW50OlN3b3JkZmlzaA==
is client:Swordfish
base64 encoded.