Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ API documentation (i.e. the RDocs) are available at http://rubycas-client.rubyfo

== Installation

<b>NOTE:</b> 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.

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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: <tt>config.action_controller.session_store = :active_record_store</tt>
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 <tt>application.rb</tt>: <tt>self.allow_forgery_protection = false</tt>.
(Or rather you may want to disable forgery protection only for actions that are behind the CAS filter.)
Expand Down Expand Up @@ -227,7 +229,7 @@ all you need to do is this:
In your <tt>config/environment.rb</tt>:

# 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(
Expand Down
10 changes: 5 additions & 5 deletions examples/rails/config/boot.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,15 +21,15 @@ def pick_boot
end

def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
File.exist?("#{Rails.root}/vendor/rails")
end

def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end

def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
"#{Rails.root}/config/preinitializer.rb"
end
end

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/rails/config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/casclient/frameworks/rails/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down