0

I have one app on abc.website.com that authenticates users using devise with Ruby on Rails. I have to setup a react app on def.website.com that only works if the user is logged in on abc.website.com (abc uses devise)

We have to add a link in the navbar of abc.website.com that redirects to def.website.com.

Any suggestions on what the best way to do this is?

I'm a total ruby noob but good with javascript.

thanks a lot appreciate the help

2 Answers2

0

Here is one of a solution : Token Based Authentication. JWT also is a fine idea.

Madao
  • 3,756
  • 1
  • 22
  • 16
0

The rails app can also store a cookie (for example use the rails session cookie) in the clients cookie store. This gets sent to the rails app on every request by the react app and you can verify the identity of the user by reading this cookie.

There are very few adjustments needed for this approach (and they would also be required for JWT - which I don't want to badmouth, it is also a viable and good approach).

An upshot of this is that almost no data needs to be stored at the client. Only an ID that makes it easy for the rails backend to identify the user and achieve all needed informations. On the other side, if you want to store all the data at client side this is also possible.

I would say there is no clear advantage of rails session over JWT or vice versa. But generally this is how it should be implemented: By giving the client the necessary information which then gets passed over to the backend again.

Jay Schneider
  • 325
  • 1
  • 7