Share session between Node.js and Rails

Hi!

I'm not an expert on Rails, but I've been doing some recent
development with it. Right now, I have a working app with devise for
authentication.

Moreover, I am building a chat with Node.js and Socket.io and I wanted
to embed the client side of the Node.js app in my Rails app, in order
to let users access the Rails app and then chat without having to
authenticate again for Node.

Is there any way to do that and at the same time be able to retrieve
the current_username from the rails database?

Thanks

Daniel A. wrote:

Hi!

I'm not an expert on Rails, but I've been doing some recent
development with it. Right now, I have a working app with devise for
authentication.

Moreover, I am building a chat with Node.js and Socket.io and I wanted
to embed the client side of the Node.js app in my Rails app, in order
to let users access the Rails app and then chat without having to
authenticate again for Node.

Is there any way to do that and at the same time be able to retrieve
the current_username from the rails database?

I have two thoughts here, though I know nothing about Node.js and little
about Ajax authentication:

1. Can you have Rails set a cookie and the JavaScript app read it (or
vice versa)?

2. Perhaps *neither* the Rails app nor the JS app should do the
authentication lookup. You might want to build a third app (probably a
Rails REST service) that handles the lookup and gives back a token of
some sort. Rails can use it through ActiveResource, and the JS app can
use it through an Ajax call.

Thanks

Best,