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 97856126..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 @@ -140,7 +140,7 @@ def filter(controller) def configure(config) @@config = config - @@config[:logger] = RAILS_DEFAULT_LOGGER unless @@config[: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