There are several implementation methods that can help you deal with this. The one that comes to mind is sharing a session cookie that is being developed using nodejs through a database.
IIRC dev creates an encrypted session cookie during authentication; temporarily store this value in your database and let nodejs pull it out of the database to authenticate it. There are probably some difficulties in doing this (porting some of the encryption methods to nodejs, etc.), but if you are making a rails / nodejs application, I'm sure you can handle it .: D
The advantage here is that the user cannot get between the distribution in order to perform the impersonation.
source share