envygeeks
10/13/2013 - 8:32 PM

Signed Redis-Store session ID's.

require 'action_dispatch/middleware/session/redis_store'

module ActionDispatch
  module Session
    class SignedRedisStore < ActionDispatch::Session::RedisStore
      def load_session(env)
        stale_session_check! do
          get_session(env, 
            cookie_jar(env)[@key]
          )
        end
      end

      def set_cookie(env, session_id, cookie)
        cookie_jar(env)[@key] = cookie
      end

      def cookie_jar(env)
        ActionDispatch::Request.new(env).
          cookie_jar.signed
      end
    end
  end
end