# Copyright (c) 2012 RightScale Inc # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'rack/contrib/cookies' # lib/global_session.rb does this for us, but just in case this file is required directly... require 'action_pack' require 'action_controller' #Require the files necessary for Rails integration require 'global_session/rack' require 'global_session/rails/action_controller_class_methods' require 'global_session/rails/action_controller_instance_methods' # Enable ActionController integration. class < e raise GlobalSession::ConfigurationError, "Unknown/malformed directory class '#{dir_name}' in config file: #{e.message}" end unless dir_klass.ancestors.include?(GlobalSession::Directory) raise GlobalSession::ConfigurationError, "Specified directory class '#{dir_name}' does not inherit from GlobalSession::Directory" end authorities_dir = File.join(::Rails.root, 'config', 'authorities') self.directory = dir_klass.new(self.configuration, authorities_dir) self.keystore = self.directory.keystore # Add our middleware to the stack. rails_config.middleware.insert_before(ActionController::Base.session_store, ::Rack::Cookies) rails_config.middleware.insert_before(ActionController::Base.session_store, ::Rack::GlobalSession, self.configuration, self.directory, &block) return true end end end