From 36e7cfda6970ce8bf63cfe0cff52b59703588b83 Mon Sep 17 00:00:00 2001 From: Anthony Kirwan Date: Wed, 3 Nov 2010 22:14:44 -0400 Subject: [PATCH 1/4] changed depricated rails constant to new rails 3 constant --- lib/casclient/frameworks/rails/filter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/casclient/frameworks/rails/filter.rb b/lib/casclient/frameworks/rails/filter.rb index 97856126..ed8bf380 100644 --- a/lib/casclient/frameworks/rails/filter.rb +++ b/lib/casclient/frameworks/rails/filter.rb @@ -140,7 +140,7 @@ def filter(controller) def configure(config) @@config = config - @@config[:logger] = RAILS_DEFAULT_LOGGER unless @@config[:logger] + @@config[:logger] = Rails.logger @@client = CASClient::Client.new(config) @@log = client.log end From 927c623e9fd80e86b0ede46b3eaa97636e652400 Mon Sep 17 00:00:00 2001 From: Anthony Kirwan Date: Mon, 14 Feb 2011 12:21:47 -0500 Subject: [PATCH 2/4] changed RAILS_ROOT to Rails.root --- README.rdoc | 8 +++++--- examples/rails/config/boot.rb | 10 +++++----- examples/rails/config/environment.rb | 2 +- .../frameworks/rails/cas_proxy_callback_controller.rb | 2 +- lib/casclient/frameworks/rails/filter.rb | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.rdoc b/README.rdoc index 2a69f68b..55769cb4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -36,6 +36,8 @@ API documentation (i.e. the RDocs) are available at http://rubycas-client.rubyfo == Installation +NOTE: For compatibility with Rails 3 have a look at https://github.com/zuk/rubycas-client-rails + You can download the latest version of RubyCAS-Client from the project's rubyforge page at http://rubyforge.org/projects/rubycas-client. @@ -105,7 +107,7 @@ Here is a more complicated configuration showing most of the configuration optio (this does not show proxy options, which are covered in the next section): # enable detailed CAS logging - cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log') + cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log') cas_logger.level = Logger::DEBUG CASClient::Frameworks::Rails::Filter.configure( @@ -146,7 +148,7 @@ notify the client application that the CAS session is closed. The client will au requsts from the CAS server, but in order for this to work you must configure your Rails application as follows: 1. The Rails session store must be set to ActiveRecord: config.action_controller.session_store = :active_record_store -2. The server must be able to read and write to RAILS_ROOT/tmp/sessions. If you are in a clustered environment, +2. The server must be able to read and write to Rails.root/tmp/sessions. If you are in a clustered environment, the contents of this directory must be shared between all server instances. 3. Cross-site request forgery protection must be disabled. In your application.rb: self.allow_forgery_protection = false. (Or rather you may want to disable forgery protection only for actions that are behind the CAS filter.) @@ -227,7 +229,7 @@ all you need to do is this: In your config/environment.rb: # enable detailed CAS logging for easier troubleshooting - cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log') + cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log') cas_logger.level = Logger::DEBUG CASClient::Frameworks::Rails::Filter.configure( diff --git a/examples/rails/config/boot.rb b/examples/rails/config/boot.rb index 6a30b549..704bfcc3 100644 --- a/examples/rails/config/boot.rb +++ b/examples/rails/config/boot.rb @@ -1,7 +1,7 @@ # Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) +Rails.root = "#{File.dirname(__FILE__)}/.." unless defined?(Rails.root) module Rails class << self @@ -21,7 +21,7 @@ def pick_boot end def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") + File.exist?("#{Rails.root}/vendor/rails") end def preinitialize @@ -29,7 +29,7 @@ def preinitialize end def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" + "#{Rails.root}/config/preinitializer.rb" end end @@ -42,7 +42,7 @@ def run class VendorBoot < Boot def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" + require "#{Rails.root}/vendor/rails/railties/lib/initializer" Rails::Initializer.run(:install_gem_spec_stubs) end end @@ -99,7 +99,7 @@ def parse_gem_version(text) private def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") + File.read("#{Rails.root}/config/environment.rb") end end end diff --git a/examples/rails/config/environment.rb b/examples/rails/config/environment.rb index 430e2735..0f0ce831 100644 --- a/examples/rails/config/environment.rb +++ b/examples/rails/config/environment.rb @@ -24,7 +24,7 @@ # More complicated configuration -#cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log') +#cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log') #cas_logger.level = Logger::DEBUG # #CASClient::Frameworks::Rails::Filter.configure( diff --git a/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb b/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb index 59c99f69..01b0e57f 100644 --- a/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb +++ b/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb @@ -71,6 +71,6 @@ def render_error(msg) end def open_pstore - PStore.new("#{RAILS_ROOT}/tmp/cas_pgt.pstore") + PStore.new("#{Rails.root}/tmp/cas_pgt.pstore") end end diff --git a/lib/casclient/frameworks/rails/filter.rb b/lib/casclient/frameworks/rails/filter.rb index ed8bf380..2453406c 100644 --- a/lib/casclient/frameworks/rails/filter.rb +++ b/lib/casclient/frameworks/rails/filter.rb @@ -140,7 +140,7 @@ def filter(controller) def configure(config) @@config = config - @@config[:logger] = Rails.logger + @@config[:logger] = Rails.logger unless @@config[:logger] @@client = CASClient::Client.new(config) @@log = client.log end @@ -400,7 +400,7 @@ def delete_service_session_lookup(st) # Returns the path and filename of the service session lookup file. def filename_of_service_session_lookup(st) st = st.ticket if st.kind_of? ServiceTicket - return "#{RAILS_ROOT}/tmp/sessions/cas_sess.#{st}" + return "#{Rails.root}/tmp/sessions/cas_sess.#{st}" end end end From 4de27a92350810e75468e7aa6225a2f44f9eb8a0 Mon Sep 17 00:00:00 2001 From: Anthony Kirwan Date: Mon, 14 Feb 2011 12:35:32 -0500 Subject: [PATCH 3/4] needed to add :: before Rails.logger in Rails::Filter --- lib/casclient/frameworks/rails/filter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/casclient/frameworks/rails/filter.rb b/lib/casclient/frameworks/rails/filter.rb index 2453406c..4dfefbd8 100644 --- a/lib/casclient/frameworks/rails/filter.rb +++ b/lib/casclient/frameworks/rails/filter.rb @@ -140,7 +140,7 @@ def filter(controller) def configure(config) @@config = config - @@config[:logger] = Rails.logger unless @@config[:logger] + @@config[:logger] = ::Rails.logger unless @@config[:logger] @@client = CASClient::Client.new(config) @@log = client.log end From d5b706fc21d06c1e4f2e5db2063aedae8b50a512 Mon Sep 17 00:00:00 2001 From: Anthony Kirwan Date: Thu, 17 Feb 2011 10:31:15 -0500 Subject: [PATCH 4/4] added reader for fake attributes --- lib/casclient/frameworks/rails/filter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/casclient/frameworks/rails/filter.rb b/lib/casclient/frameworks/rails/filter.rb index 4dfefbd8..1b7b1f7d 100644 --- a/lib/casclient/frameworks/rails/filter.rb +++ b/lib/casclient/frameworks/rails/filter.rb @@ -2,7 +2,7 @@ module CASClient module Frameworks module Rails class Filter - cattr_reader :config, :log, :client + cattr_reader :config, :log, :client, :fake_user, :fake_extra_attribues # These are initialized when you call configure. @@config = nil @@ -18,7 +18,7 @@ def filter(controller) if @@fake_user controller.session[client.username_session_key] = @@fake_user controller.session[:casfilteruser] = @@fake_user - controller.session[client.extra_attributes_session_key] = @@fake_extra_attributes + controller.session[client.extra_attributes_session_key] = @@fake_extra_attributes return true end