How does warden get the current user from the rack session?
Asked Answered
M

0

6

After the user has logged in (ENV['warden'].authenticate!'d) once, how does warden know this? I can not find anything in the cookie except for the rack.session value - I couldn't figure this out from the documentation or code.

Madwort answered 4/9, 2015 at 15:31 Comment(5)
Can you elaborate the question? env['rack.session'] contains the session for this specific user, and contains a warden.user.key or something...Birdella
@Birdella But where is that stored on the server? It seems to be Marshalled here (github.com/rack/rack/blob/master/lib/rack/session/cookie.rb) but I can't find where it's being stored. There seems to be two options: Memcached and Pooled, but can't find which one is the default, and which is used when. I do know that it persists after server shutdown, so memcached?Madwort
Are you sure it persists over restarts? The default is Pool, which stores data in a Hash: github.com/rack/rack/blob/master/lib/rack/session/pool.rb#L33Birdella
I am sure it persists after I restart the server.Madwort
Fun stuff... so the question is, how does rack persist sessionsBirdella

© 2022 - 2024 — McMap. All rights reserved.