lib/global_session/rack.rb in global_session-3.2.0 vs lib/global_session/rack.rb in global_session-3.2.1
- old
+ new
@@ -35,10 +35,13 @@
attr_accessor :configuration
# @return [GlobalSession::Directory]
attr_accessor :directory
+ # @return [GlobalSession::Keystore]
+ attr_accessor :keystore
+
# Make a new global session middleware.
#
# The optional block here controls an alternate ticket retrieval
# method. If no ticket is stored in the cookie jar, this
# function is called. If it returns a non-nil value, that value
@@ -96,13 +99,10 @@
else
raise GlobalSession::ConfigurationError,
"Cannot determine directory class/instance; method parameter is a #{directory.class.name} and configuration parameter is #{klass.class.name}"
end
- # Initialize the keystore
- @keystore = Keystore.new(@configuration)
-
@cookie_retrieval = block
@cookie_name = @configuration['cookie']['name']
end
# Rack request chain. Sets up the global session ticket from
@@ -200,12 +200,12 @@
# Renew the session ticket.
#
# @return [true] always returns true
# @param [Hash] env Rack request environment
def renew_cookie(env)
- return unless @configuration['authority']
- return if env['global_session.req.renew'] == false
+ return true unless @directory.local_authority_name
+ return true if env['global_session.req.renew'] == false
if (renew = @configuration['renew']) && env['global_session'] &&
env['global_session'].expired_at < Time.at(Time.now.utc + 60 * renew.to_i)
env['global_session'].renew!
end
@@ -216,11 +216,11 @@
# Update the cookie jar with the revised ticket.
#
# @return [true] always returns true
# @param [Hash] env Rack request environment
def update_cookie(env)
- return true unless @directory.keystore.private_key_name
+ return true unless @directory.local_authority_name
return true if env['global_session.req.update'] == false
session = env['global_session']
if session
@@ -259,11 +259,11 @@
# Delete the global session cookie from the cookie jar.
#
# @return [true] always returns true
# @param [Hash] env Rack request environment
def wipe_cookie(env)
- return unless @directory.keystore.private_key_name
- return if env['global_session.req.update'] == false
+ return true unless @directory.local_authority_name
+ return true if env['global_session.req.update'] == false
env['rack.cookies'][@cookie_name] = {:value => nil,
:domain => cookie_domain(env),
:expires => Time.at(0)}