[英]Devise rails session ID
事實證明,在登錄后,在使用Devise(身份驗證gem)(在session_controller
或after_sign_in_path_for
)登錄后獲得會話ID(帶有session[:session_id]
)不會在第一次重定向前后返回相同的結果,在。
有人能解釋我為什么嗎? 有什么辦法可以在重定向之前獲取最終的會話ID?
僅供參考,來自Gee-Bee( https://github.com/Gee-Bee ):
https://github.com/plataformatec/devise/issues/3706
Is anyone can explain me why ?
我會盡力。 簡而言之:
Devise has nothing to do with it Warden has something to do with it - it's setting :renew option on session, after setting user (proxy, spec) Actual action takes place in in Rake::Session::Abstract#commit_session which updates session_id (by
調用在ActionDispatch :: Session :: CookieStore中實現的destroy_session和set_session)
Is there any way to get the final session ID before redirecting ?
當然是啦。 請記住,Warden會在身份驗證后更改session_id,以防止會話固定攻擊,因此,在禁用的devise控制器中,除了禁用:renew session選項之外,您還應該手動更改session_id。 這樣可以:
session.options [:id] = session.instance_variable_get(:@ by).generate_sid session.options [:renew] = false
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.