简体   繁体   English

最新的 omniauth-facebook gem 破解 devise

[英]Latest omniauth-facebook gem breaks devise

ruby '2.6.3' gem 'rails', '~> 6.0.2', '>= 6.0.2.1' ruby '2.6.3' gem 'rails', '~> 6.0.2', '>= 6.0.2.1'

I'm using the latest omniauth-facebook and devise together Gemfile: gem 'devise' gem 'omniauth-facebook'我一起使用最新的 omniauth-facebook 和 devise Gemfile: gem 'devise' gem 'omniauth-facebook'

Getting this error when starting the server:启动服务器时出现此错误:

/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. /versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `': 您使用的是旧的 OmniAuth 版本,请确保您已安装 1.0.0.pr2 版本或更高版本。 (RuntimeError) (运行时错误)

The problem is that if I try to use older omniauth-facebook versions the server works but then the Facebook authentication stops working properly (eg fails including emails despite问题是,如果我尝试使用较旧的 omniauth-facebook 版本,服务器可以正常工作,但随后 Facebook 身份验证将停止正常工作(例如,尽管包括电子邮件在内,但仍然失败

scope: 'email', info_fields: 'email,name' scope: 'email', info_fields: 'email,name'

in devise.rb.在 devise.rb。 ) )

I have tried many different version combinations of omniauth-facebook and devise. Either Facebook-authentication stops working properly or the server fails (see above).我已经尝试了 omniauth-facebook 和 devise 的许多不同版本组合。要么 Facebook 身份验证停止正常工作,要么服务器出现故障(见上文)。

Using使用

gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2'

In Gemfile will fix the problem, awaiting a merge.在 Gemfile 中将解决问题,等待合并。

Updated my answer based on Carlos answer below, I was in a rush when I posted this using ref.根据下面的 Carlos 回答更新了我的答案,当我使用 ref 发布这个时我很着急。

Thank You, Carlos for maintaining Devise.谢谢 Carlos 维护 Devise。

This is Carlos, Devise maintainer.这是 Carlos,Devise 维护者。 Please keep an eye on that Pull Request linked above, I just shared how you can test it in your app there :请留意上面链接的 Pull Request,我刚刚分享了如何在您的应用程序中测试它

I'd recommend using the branch ref instead of the git ref directly:我建议直接使用 branch ref 而不是 git ref:

gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2'

With that you should be able to run bundle update devise omniauth which should hopefully give you OmniAuth 2 and this Devise branch.有了它,你应该能够运行bundle update devise omniauth ,它应该会给你 OmniAuth 2 和这个 Devise 分支。 That should allow the app to boot up.这应该允许应用程序启动。

Lastly, if you've copied over the Devise shared links on your app, or if you have your own links to initiate the OmniAuth authentication flow, you need to make sure they're changed to use a form.最后,如果您在应用程序上复制了 Devise 共享链接,或者如果您有自己的链接来启动 OmniAuth 身份验证流程,则需要确保将它们更改为使用表单。 (you can do that by using link_to with method: :post option for example, or using button_to , if that works for your app.) Please note that this is a requirement change in how OmniAuth work due to a security issue, read more . (例如,您可以将 link_to 与method: :post选项一起使用,或者使用button_to ,如果这适用于您的应用程序。)请注意,由于安全问题,这是对 OmniAuth 工作方式的要求更改,请阅读更多

If you run into any issues please comment back in GitHub, and we'll work to get them resolved soon so we can release a new Devise version that fully supports OmniAuth 2. Thanks.如果您遇到任何问题,请在 GitHub 中回复,我们将尽快解决这些问题,以便我们发布完全支持 OmniAuth 2 的新版本 Devise。谢谢。

Devise 4.8.0 (shipped yesterday) resolves this. Devise 4.8.0(昨天发货)解决了这个问题。

Please downgrade OmniAuth:请降级 OmniAuth:

gem "omniauth", "~> 1.9.1"

That's worked for me.这对我有用。

I'm pretty sure the issue is related to this devise PR, https://github.com/heartcombo/devise/pull/5327我很确定这个问题与这个 devise PR, https://github.com/heartcombo/devise/pull/5327有关

Devise currently has a version check that doesn't include OmaniAuth > 1.xx Devise 当前的版本检查不包括 OmaniAuth > 1.xx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM