I am trying to setup a user login system with Node.js (Express), Socket.io, and Redux/ReactJS. This is the approach I'm taking:
- The user connects through Socket.io as soon as he/she gets to the web app.
- Through socketio-auth the user is required to authenticate and passes their username and password to the server.
- Then, using socket.io-express-session, like in this example, I set a cookie with the user's username and password, so that every time they come back to the website they can be re-authenticated through socketio-auth. (I realize I could probably save a unique token in the cookie instead, would this be better?)
- On the server, upon authentication, I just save their details with their socketId to the Redux store for use with every Socket.io request while the session lasts.
Assuming this is all done over SSL
, is this safe? What changes would you suggest? I'm trying to make it as simple as possible yet still very safe.