Ruby on rails 如何为omniauth OpenID禁用发现并指定OpenID服务器

Ruby on rails 如何为omniauth OpenID禁用发现并指定OpenID服务器,ruby-on-rails,ruby-on-rails-3,openid,omniauth,google-openid,Ruby On Rails,Ruby On Rails 3,Openid,Omniauth,Google Openid,我正在尝试用RubyonRails中的Google应用程序实现OmniAuthOpenID。我知道如果我指定“:identifier=>”的话,它应该是开箱即用的https://www.google.com/accounts/o8/site-xrds?hd=example.com“,其中example.com是我的目标用户来自的域 用户在访问/auth/Google时可以被重定向到Google,而这个openid.identity可以从Google返回: ... &openid.iden

我正在尝试用RubyonRails中的Google应用程序实现OmniAuthOpenID。我知道如果我指定“:identifier=>”的话,它应该是开箱即用的https://www.google.com/accounts/o8/site-xrds?hd=example.com“,其中example.com是我的目标用户来自的域

用户在访问/auth/Google时可以被重定向到Google,而这个openid.identity可以从Google返回:

... &openid.identity=http://example.com/openid?id=xxxxxxxxxxxxxxxxxxxxxxx ...
但是,我正在使用的example.com没有在上设置正确的“rel='openid2.provider'”标记,因此当omniauth openid再次尝试与Google进行检查时,发现失败

是否有一种快速而干净的方法来解决默认的发现行为,以便我可以直接定义为服务器而不执行自动发现


谢谢

我认为omniauth openid使用ruby openid。如果是这样,您应该能够轻松地使其工作:

gem install ruby-openid-apps-discovery
然后在提出请求之前,在某个地方加入

require 'gapps_openid'

Google Apps有一个稍微不同的发现协议,这是gem提供的。

在使用Steve推荐的gem之前,我想出了一个解决方案,使整个发现过程只在本地进行,我发现这可能对一些人有用。如果您只接受来自单个Google Apps域的用户,您可能希望:

  • 在/etc/hosts中添加一行,如
    127.0.0.1 example.com

  • 设置一个轻量级的HTTP服务器,比如nginx,创建一个名为
    openid
    (不要附加.html)的文件,并在那里添加标记


  • 这比使用ruby openid apps discovery稍微快一点,因为它可以避免应用程序向外部https服务器发送某些请求。

    谢谢!这正是我想要的。