Auth user between Rails apps with JWT token

207 views Asked by At

My problem: I'm adding a store section to a rails 5 api only app and to keep the complexity down I'm planning to add it as a separate macroserivce and share the user between the two apps, to auth the users in the main app I'm using a JWT token and I would like to use the same token in both apps.

My not working solution: Use rabbitMQ to send the token from the store to the main app and get back all the user information I need from it. searching around I found this article and tutorial:

https://engineering.adwerx.com/building-a-macroservice-on-rails-with-rabbitmq-and-sneakers-8a394e014a94

https://www.rabbitmq.com/tutorials/tutorial-six-ruby.html

and from those I come up with this solution (I know is absolutely not production ready but I'm trying to get a working MVP before that):

https://gist.github.com/jabawack81/5cfc0983ebd3166fadcd683f335456f0

The problem is: I'm getting the token from the header in the store application controller and I'm able to push it in the queue (inspecting the queue with rabbitMQ GUI) the main app is receiving it, process it but is not replying back.

0

There are 0 answers