I am using the https server Node.js, which performs authentication using HTTP Basic (which is fine, as the data is transmitted over an SSL-encrypted connection).
Now I want to provide a Socket.io connection, which should be
- encrypted and
- Only for authenticated users.
The question is how to do this. I already figured out what I need to specify { secure: true }in the client JavaScript code when connecting to the socket, but how can I force socket connections on the server side to be launched only via SSL and that it works only for authentication users?
I think the SSL business is the easy part, as the Socket.io server is only tied to the https server, so it should only work using SSL, and it should not be possible to run it on top of the (optional) running http server, right?
As for the other thing, I have no idea how to ensure that socket connections can only be established after successful authentication of the user using HTTP Basic.
Any ideas?
source
share