问题
I'm have omniauth working in my Rails app on the top level domain.
Now I want to do it on any given subdomain (users each get their own subdomain assigned dynamically).
I can't find a way to dynamically change the callback url on the fly with omniauth
Leaving it as is, in the callback I can see the referrer and know which subdomain they came from, and log them in, but when I then redirect them to their subdomain they are logged out because the session was on the top level domain.
I'm using the omniauth-facebook gem if that matters: https://github.com/mkdynamic/omniauth-facebook
What's the best way to handle this?
回答1:
I don't think that Omniauth let's you change this dynamically, but you can share the session between all subdomains, and continue to use the redirection approach. Just change your session_store
to include domain
(and tld_length
if you need it - more details here)
Rails.application.config.session_store ... , domain: :all
来源:https://stackoverflow.com/questions/42894189/how-to-do-omniauth-on-wildcard-subdomain