Finally found the root of the problem and why it was reproduced only when using warden.
Well, actually when you successfully sign in with devise/warden, the method set_user inside warden/proxy.rb file is called to store the user into the session.
The following snippet is from this method:
def set_user(user, opts = {})
scope = (opts[:scope] ||= @config.default_scope)
# Get the default options from the master configuration for the given scope
opts = (@config[:scope_defaults][scope] || {}).merge(opts)
opts[:event] ||= :set_user
@users[scope] = user
if opts[:store] != false && opts[:event] != :fetch
options = env[ENV_SESSION_OPTIONS]
options[:renew] = true if options
session_serializer.store(user, scope)
end
....
@users[scope]
end
The line in bold which sets the renew option is what causes jruby-rack's session_store to fail.
In jruby-rack now, the servlet session store is defined in
session_store.rb and has overriden some methods from Rack::Session::Abstract::ID.
The one that matters here is the commit_session method.
I think that the problem lies in that the "renew" option isn't accurately interpreted.
# :renew (implementation dependent) will prompt the generation of a new session id, and migration of data to be referenced at the new id
the session store overrides the commit_session and instead of doing :
if options[:drop] || options[:renew]
session_id = destroy_session(env, options[:id] || generate_sid, options)
return [status, headers, body] unless session_id
end
it does the following:
if options[:drop] || options[:renew]
destroy_session(env, options[:id], options)
return [status, headers, body]
end
From what I can understand by a first look is that the servlet store, instead of destroying the session and reissuing a new copy of it, it just invalidates the underlying servlet session.
https://github.com/jruby/jruby-rack/commit/de94b634d88770cd629182f70f8cc27d2af72837Do you think I should open an issue on jruby-rack?
Thanks a lot