Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I share authentication on a rails/rack app with a node.js instance?

I have been trying to figure out how to integrate a node.js app into a rails app and having them share sessions. I've so far only been able to dig up sharing sessions between sinatra and ruby on rails via rack middleware. Is it possible to to do this?

I thought of a workaround involving the ror implementing a rest service that "poops" out a guid that node.js can use to create its own session. This solution however requires having model validations ad such stored in two seperate apps.

just wondering if there was a way to integrate them.

and while using a js based webframework like geddy or express is cool, I have alot of existing rails code and 3rd party libraries such as active merchant that I would have to reinvent.

like image 909
cultofmetatron Avatar asked Dec 16 '10 01:12

cultofmetatron


People also ask

What is Nodejs connect?

Connect is an extensible HTTP server framework for node using "plugins" known as middleware.

What is Rack middleware?

Rack middleware is a way to filter a request and response coming into your application. A middleware component sits between the client and the server, processing inbound requests and outbound responses, but it's more than interface that can be used to talk to web server.


1 Answers

how about using something like memcached to share a validation mechanism, for example set a session in rails and for every message to the nodeJs server a token is given, nodeJs checks on memcached if the token exists and grants or denies based on that. You would of course add the record on memcached from the rails app

like image 134
Purefan Avatar answered Nov 08 '22 09:11

Purefan