Friday 21 April 2017

Implementing websockets for logged-in users in website

Looking for referrals to articles/tutorials since my search did not come out fruitful.

In my website, I use oauth to authenticate users. Now we would like to implement websockets for push notifications.

The problem is, since the user logged in via http, I am not sure how to make sure they are authenticated when using websockets since

req.isAuthenticated()

is not available obvisouly.

Once I am able to authenticate the user, I also don't understand how I can associate the user's ID from the DB with the socket.

Desired scenario:

  1. User logs in via web http interface.
  2. Once the user is authenticated, a websocket is opened between the client and the server
  3. Through the websocket I am able to communicate to the server that the requesting client has [someID] that was retrieved during the log-in process, and that is also availble via req.user._id

What would be some good articles to start with?

Thank you!



via Michael Seltenreich

No comments:

Post a Comment