【问题标题】:Devise + Omniauth [WARNING: Can't verify CSRF token authenticity]Devise + Omniauth [警告:无法验证 CSRF 令牌的真实性]
【发布时间】:2011-11-15 16:01:15
【问题描述】:

我收到此警告

WARNING: Can't verify CSRF token authenticity

就在我的回调操作运行之前,即

Started GET "/users/auth/open_id?openid_url=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid" for 98.xxx.xx.xx at 2011-09-12 16:26:02 -0400
Started GET "/users/auth/open_id/callback?openid_url=https%3A%2%2Fwww.google.com%2Faccounts ... etc ... etc
Processing by Users::OmniauthCallbacksController#open_id as HTML
Parameters: {"openid_url"=>"https://www.google.com/accounts/o8/id"}
WARNING: Can't verify CSRF token authenticity
Entering Users::OmniauthCallbacksController, omniauth_login

对于直接来自浏览器的请求没有警告。我正在使用 rails 3.1,devise 1.4.5,omniauth 0.2.6。

关于如何解决这个问题的想法?

谢谢!

【问题讨论】:

    标签: ruby-on-rails devise csrf omniauth


    【解决方案1】:

    关闭protect_from_forgery 对我有用。

    【讨论】:

    • 你能说得更具体些吗?在哪里/如何关闭它?仅适用于 openid 身份验证?否则听起来可能会导致潜在的安全漏洞......
    • 只有在知道自己在做什么的情况下才应该这样做。如果您要根据 StackOverflow 的回答关闭 protect_from_forgery,那么您不知道您在做什么!
    猜你喜欢
    • 2017-07-19
    • 2013-05-30
    • 2011-11-04
    • 2023-04-11
    • 2013-06-16
    • 1970-01-01
    • 2012-04-27
    相关资源
    最近更新 更多