如何在通配符子域上进行 omniauth [英] How to do omniauth on wildcard subdomain

查看:61
本文介绍了如何在通配符子域上进行 omniauth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在顶级域的 Rails 应用中使用 omniauth.

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).

  • 我找不到使用 omniauth 动态更改回调 url 的方法

  • 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.

如果重要的话,我正在使用 omniauth-facebook gem:https://github.com/mkdynamic/omniauth-facebook

I'm using the omniauth-facebook gem if that matters: https://github.com/mkdynamic/omniauth-facebook

处理这个问题的最佳方法是什么?

What's the best way to handle this?

推荐答案

我认为 Omniauth 不会让您动态更改此设置,但是您可以在所有子域之间共享会话,并继续使用重定向方法.只需更改您的 session_store 以包含 domain(如果需要,还可以包含 tld_length - 更多详情这里)

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

这篇关于如何在通配符子域上进行 omniauth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆