how to authenticate user

75 views
Skip to first unread message

Dennis Dowhy

unread,
Mar 17, 2014, 5:20:52 PM3/17/14
to soc...@googlegroups.com
If I have an HTTP/HTTPS client that is already SAML authenticated, what is the recommended practice for authenticating a subsequent WS/WSS sockjs connection from that same user?  

My understanding is that websocket doesn't provide authentication so you have to use another mechanism... perhaps reusing sessionIDs or cookies?  Are there examples of this somewhere?

<--sockjs/websocket noob
Message has been deleted

Chris-S

unread,
Mar 25, 2014, 10:51:27 PM3/25/14
to soc...@googlegroups.com
sockjs creates a random ID on socket connection, (example = connection.id), this ID is safe to use for the duration of the socket.
sockjs knows when this socket has been connected and disconnected (example socket.onclose(your function here) ) , run your logic from these events.

This has nothing to do with an HTTP session... the socket session only lasts as long as the socket connection to the server, and is cut when the page reloads, or the browser window/tab is closed, or in some cases when the internet connection is dodgy.

It's up to you to send Auth info to your server, for example for verification against a DB. 
e.g. socket.send({command:"auth",name:name,pass:pass});

Personally I use the ID for a looped reconnection attempt on an unexpected socket.onclose(), resending the old ID as data to the server - the server matches it from a list to revalidate, if correct updates the list to the new ID.
e.g. socket.send({command:"re-connect",old_id:old_id});





Reply all
Reply to author
Forward
0 new messages