Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to share tokens across subdomains using devise-token-auth? #1199

Closed
link2prasad opened this issue Aug 5, 2018 · 4 comments
Closed

How to share tokens across subdomains using devise-token-auth? #1199

link2prasad opened this issue Aug 5, 2018 · 4 comments

Comments

@link2prasad
Copy link

We are working on app which uses React, Rails (5.2) with devise-token-auth(0.1.43) for authentication . The app has multiple subdomains and we would like to share same user-token across all subdomains. However the old token is un-identified when user gets into a new sub-domain. And application prompts user to login page when he enters a subdomain.

In rails we configured common session_store for all subdomains. As well updated the Rack middleware to apply those changes.

config.session_store :cookie_store,
:key => '_yourappsession',
:domain => :all
On the browser (chrome) we can able to see cookie_store being shared across main domain and subdomain pages. However user session/token is not shared between them.

Is there a way to share token across subdomains?

@kjanoudi
Copy link

Did you figure this out @link2prasad ?

@link2prasad
Copy link
Author

It's still open.

@abchandra
Copy link

The short answer is that's a react question, not a devise token auth question - you need to figure out how share your tokens between subdomains. NB that this is not possible if you only use local storage on your front end, so you'll have to find some way to store the tokens as cookies that shared by the top level domain and then use those cookies to authenticate against the (single) backend.

@MaicolBen
Copy link
Collaborator

@abchandra is right, we don't use cookies, so it's a frontend issue. You can use something like https://github.com/ofirdagan/cross-domain-local-storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants