Rails 3.2应用程序在Heroku与Devise:无法登录与移动Safari [英] Rails 3.2 app on Heroku with Devise: Can't log in with Mobile Safari
问题描述
Heroku日志说如下:
2012-10-17T18 :56:52 + 00:00 app [web.1]:开始POST/ users / sign_in为87.123.175.106在2012-10-17 20:56:52 +0200
2012-10-17T18: 56:52 + 00:00 app [web.1]:由Devise :: SessionsController处理#创建为HTML
2012-10-17T18:56:52 + 00:00 app [web.1]:参数: {utf8=>✓,authenticity_token=>SHHVgAxRFJ8VFu2cnbh / YGn6s6q0L9Mnp24x9Whu2mk =,user=> {name=>test,password=>[FILTERED ],commit=>anmelden}
2012-10-17T18:56:52 + 00:00 app [web.1]:警告:无法验证CSRF令牌的真实性
2012-10-17T18:56:53 + 00:00 app [web.1]:重定向到http://xxxxxxxx.herokuapp.com/
其他iOS浏览器(如Opera)不会出现此问题。
我没有做任何自定义的东西来设计(除了添加用户名),它几乎非常开箱即可实现。
我有阅读几个帖子,其中iOS和CSRF令牌的问题被模糊地解决,但我是rails,而不是真的知道如何解决这个问题。有人可以帮忙吗?
更新:
根据这个的帖子,我评论了<$ c application_controller.rb中的$ c> protect_from_forgery 以及application.html.erb中的 csrf_meta_tags
。
另外,我添加了:domain => :all
to config / session_store.rb。
没有任何帮助。我不明白,我没有得到不能验证CSRF令牌真实性
错误,但以下日志:
2012-10-18T18:19:03 + 00:00 app [web.1]:在2012-10-18 20:20开始POST/ users / sign_in为87.123.130.136 20: 19:03 +0200
2012-10-18T18:19:03 + 00:00 app [web.1]:由Devise :: SessionsController处理#创建为HTML
2012-10-18T18:19 :03 + 00:00 app [web.1]:参数:{utf8=>✓,authenticity_token=>Q + fF + 9Sj2Q + X2VV34Jkrt1K8C3u4 / NB6YC3yslYjkyQ =,user=> ; {name=>test,password=>[FILTERED]},commit=>anmelden}
2012-10-18T18:19:03 + 00 :00 heroku [路由器]:POST pacific-beyond-5428.herokuapp.com/users/sign_in dyno = w
eb.1 queue = 0 wait = 0ms service = 783ms status = 302 bytes = 107
2012-10-18T18:19:03 + 00:00 app [web.1]:重定向到http://pacific-beyond-5428.herokuapp.com/
2012-10-18T18:19:03+ 00:00 app [web.1]:已完成302找到577ms(ActiveRecord:0.0ms)
2012-10-18T18:19:04 + 00:00 app [web.1]:
2012-10-18T18:19:04 + 00:00 app [web.1]:
2012-10-18T18:19:04 + 00:00 app [web.1]:开始GET /为87.123.130.136在2012-10-18 20:19:04 +0200
2012-10-18T18:19:04 + 00:00 app [web.1]:HomeController#index处理HTML
2012-10-18T18:19:04 + 00:00 app [web.1]:完成401未授权在0ms
2012-10-18T18:19:04 + 00:00 heroku [路由器]:GET pacific-beyond-5428.herokuapp.com/ dyno = web.1 queue = 0 wait = 0ms service = 12ms status = 302 bytes = 120
2012-10-18T18:19:04 + 00:00 app [web.1]:
2012-10-18T18:19:04 + 00:00 app [web.1]:在2012年10月20日发布了87.123.130.136的/ users / sign_in20 :19:04 +0200
2012-10-18T18:19:04 + 00:00 app [web.1]:由Devise :: SessionsController处理新的HTML
2012-10-18T18: 19:04 + 00:00 app [web.1]:
2012-10-18T18:19:04 + 00:00 app [web.1]:渲染布局/ _navigation.html.erb(1.4ms)
2012-10-18T18:19:04 + 00:00 app [web.1]:渲染设计/共享/ _links.html.erb(0.7ms)
2012-10-18T18:19: 04 + 00:00 app [web.1]:Rend ered devise / sessions / new.html.erb in layouts / application(25.5ms)
2012-10-18T18:19:04 + 00:00 app [web.1]:渲染布局/ _messages.html.erb (0.4ms)
2012-10-18T18:19:04 + 00:00 app [web.1]:渲染布局/ _sidebar.html.erb(0.3ms)
2012-10-18T18: 19:04 + 00:00 app [web.1]:在33ms完成200 OK(浏览次数:31次| ActiveRecord:0.0ms)
2012-10-18T18:19:04 + 00:00 heroku [路由器]:GET pacific-beyond-5428.herokuapp.com/users/sign_in dyno = web.1 queue = 0 wait = 0ms service = 44ms status = 200 bytes = 2361
2012-10-18T18:19:04 + 00:00 app [web.1]:
2012-10-18T18:19:04 + 00 :00 app [web.1]:
2012-10-18T18:19:04 + 00:00 app [web.1]:开始获取87.123.130.136的/assets/foundation/app.js 2012-10-18 20:19:04 +0200
2012-10-18T18:19:05 + 00:00 app [web.1]:编译基础/ app.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:服务资产/foundation/app.js - 304未修改(282ms)
2012-10-18T18:19: 05 + 00:00 heroku [路由器]:GET pacific-beyond-5428.herokuapp.com/assets/foundation/app.js dyno = web.1 queue = 0 wait = 0ms service = 297ms status = 304 bytes = 0
2012-10-18T18:19:05 + 00:00 app [web.1]:
2012-10-18T18:19:05 + 00:00 app [web.1]:
2012-10-18T18:19:05 + 00:00 app [web.1]:在2012年10月20日20:19:05开始获取/assets/foundation/index.js为87.123.130.136 +0200
2012-10-18T18 :19:05 + 00:00 heroku [路由器]:GET pacific-beyond-5428.herokuapp.com/assets/foundation/index.js dyno = web.1 queue = 0 wait = 0ms service = 905ms status = 304 bytes = 0
2012-10-18T18:19:05 + 00:00 app [web.1]:编译基础/ modernizr.foundation.js(0ms)(pid 2)
2012-10-18T18: 19:05 + 00:00 app [web.1]:编译的基础/ jquery.placeholder.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web。 1]:编译的基础/ jquery.foundation.alerts.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译的基础/ jquery.foundation .accordion.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译的基础/ jquery.foundation.buttons.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译基础/ jquery.foundation.tooltips.js(0ms)(pid 2)
2012-10 -18T18:19:05 + 00:00 app [web.1]:编译基础/ jquery.foundation.forms.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00: 00 app [web.1]:编译的基础/ jquery.foundation.tabs.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译基础/ jquery.foundation.navigation.js(0ms)(pid 2)
2012-10 -18T18:19:05 + 00:00 app [web.1]:编译基础/ jquery.foundation.topbar.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00: 00 app [web.1]:编译的基础/ jquery.foundation.reveal.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译基础/ jquery.foundation.orbit.js(0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译的基础/ jquery.foundation.mediaQueryToggle.js (0ms)(pid 2)
2012-10-18T18:19:05 + 00:00 app [web.1]:编译的基础/ index.js(86ms)(pid 2)
2012- 10-18T18:19:05 + 00:00 app [web.1]:服务资产/foundation/index.js - 304未修改(616ms)
有人想法?
我有同样的错误看到相同的症状在Heroku日志中生产:
-
警告:无法验证CSRF t oken真实性
- 登录尝试后401未经授权的重定向。
我的解决方案是将 domain::all
添加到 config中的
。 session_store
/initializers/session_store.rb
I've built an simple rails app and am deploying it to heroku. The app uses devise for authentication. Everything works fine in development and production environment, ACCEPT when one tries to log in via the Mobile Safari browser on iOS.
Heroku logs say the following:
2012-10-17T18:56:52+00:00 app[web.1]: Started POST "/users/sign_in" for 87.123.175.106 at 2012-10-17 20:56:52 +0200
2012-10-17T18:56:52+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2012-10-17T18:56:52+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"SHHVgAxRFJ8VFu2cnbh/YGn6s6q0L9Mnp24x9Whu2mk=", "user"=>{"name"=>"test", "password"=>"[FILTERED]"}, "commit"=>"anmelden"}
2012-10-17T18:56:52+00:00 app[web.1]: WARNING: Can't verify CSRF token authenticity
2012-10-17T18:56:53+00:00 app[web.1]: Redirected to http://xxxxxxxx.herokuapp.com/
The problem doesn't occur with other iOS browsers such as Opera. I didn't do any custom stuff to devise (except for adding a user name), it is implemented pretty much out of the box.
I have read several posts where the issue with iOS and CSRF token is vaguely addressed, but I'm pretty new to rails and don't really know how to fix this. Can anyone help, please?
UPDATE:
As advised in this post, I commented out protect_from_forgery
in application_controller.rb as well as the csrf_meta_tags
in application.html.erb.
Also, I added :domain => :all
to config/session_store.rb.
Nothing helped. Obiously, I don't get the Can't verify CSRF token authenticity
error anymore, but the following logs:
2012-10-18T18:19:03+00:00 app[web.1]: Started POST "/users/sign_in" for 87.123.130.136 at 2012-10-18 20:19:03 +0200
2012-10-18T18:19:03+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2012-10-18T18:19:03+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"Q+fF+9Sj2Q+X2VV34Jkrt1K8C3u4/NB6YC3yslYjkyQ=", "user"=>{"name"=>"test", "password"=>"[FILTERED]"}, "commit"=>"anmelden"}
2012-10-18T18:19:03+00:00 heroku[router]: POST pacific-beyond-5428.herokuapp.com/users/sign_in dyno=w
eb.1 queue=0 wait=0ms service=783ms status=302 bytes=107
2012-10-18T18:19:03+00:00 app[web.1]: Redirected to http://pacific-beyond-5428.herokuapp.com/
2012-10-18T18:19:03+00:00 app[web.1]: Completed 302 Found in 577ms (ActiveRecord: 0.0ms)
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]: Started GET "/" for 87.123.130.136 at 2012-10-18 20:19:04 +0200
2012-10-18T18:19:04+00:00 app[web.1]: Processing by HomeController#index as HTML
2012-10-18T18:19:04+00:00 app[web.1]: Completed 401 Unauthorized in 0ms
2012-10-18T18:19:04+00:00 heroku[router]: GET pacific-beyond-5428.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=12ms status=302 bytes=120
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]: Started GET "/users/sign_in" for 87.123.130.136 at 2012-10-18 20:19:04 +0200
2012-10-18T18:19:04+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (1.4ms)
2012-10-18T18:19:04+00:00 app[web.1]: Rendered devise/shared/_links.html.erb (0.7ms)
2012-10-18T18:19:04+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (25.8ms)
2012-10-18T18:19:04+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.4ms)
2012-10-18T18:19:04+00:00 app[web.1]: Rendered layouts/_sidebar.html.erb (0.3ms)
2012-10-18T18:19:04+00:00 app[web.1]: Completed 200 OK in 33ms (Views: 31.9ms | ActiveRecord: 0.0ms)
2012-10-18T18:19:04+00:00 heroku[router]: GET pacific-beyond-5428.herokuapp.com/users/sign_in dyno=web.1 queue=0 wait=0ms service=44ms status=200 bytes=2361
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]:
2012-10-18T18:19:04+00:00 app[web.1]: Started GET "/assets/foundation/app.js" for 87.123.130.136 at 2012-10-18 20:19:04 +0200
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/app.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Served asset /foundation/app.js - 304 Not Modified (282ms)
2012-10-18T18:19:05+00:00 heroku[router]: GET pacific-beyond-5428.herokuapp.com/assets/foundation/app.js dyno=web.1 queue=0 wait=0ms service=297ms status=304 bytes=0
2012-10-18T18:19:05+00:00 app[web.1]:
2012-10-18T18:19:05+00:00 app[web.1]:
2012-10-18T18:19:05+00:00 app[web.1]: Started GET "/assets/foundation/index.js" for 87.123.130.136 at 2012-10-18 20:19:05 +0200
2012-10-18T18:19:05+00:00 heroku[router]: GET pacific-beyond-5428.herokuapp.com/assets/foundation/index.js dyno=web.1 queue=0 wait=0ms service=905ms status=304 bytes=0
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/modernizr.foundation.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.placeholder.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.alerts.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.accordion.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.buttons.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.tooltips.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.forms.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.tabs.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.navigation.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.topbar.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.reveal.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.orbit.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/jquery.foundation.mediaQueryToggle.js (0ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Compiled foundation/index.js (86ms) (pid 2)
2012-10-18T18:19:05+00:00 app[web.1]: Served asset /foundation/index.js - 304 Not Modified (616ms)
Somebody an Idea?
I had this same errorm seeing the same symptoms on production in the Heroku logs of:
WARNING: Can't verify CSRF token authenticity
- And the 401 Unauthorized redirect after login attempt.
The resolution for me was to add domain: :all
to the session_store
in config/initializers/session_store.rb
.
这篇关于Rails 3.2应用程序在Heroku与Devise:无法登录与移动Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!