How to do omniauth on wildcard subdomain

泄露秘密 提交于 2021-01-27 23:07:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!