From e17c1e164478fe558b7b74b2dc2641bf9ee9ee99 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Fri, 4 Dec 2009 13:21:22 -0500 Subject: [PATCH] Make it possible to run rake gems:install for cas The hard requires were causing rake to fail before it could even install the rubycas-client gem. This kind of sucked. --- app/controllers/application_controller.rb | 10 +++++++--- config/environment.rb | 15 ++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f6ff4d6c..85478213 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -33,10 +33,14 @@ class ApplicationController < ActionController::Base # This will allow the user to view the index page without authentication # but will process CAS authentication data if the user already # has an SSO session open. - before_filter CASClient::Frameworks::Rails::GatewayFilter, :only => :login + if (CASClient rescue nil) + # Only require sub-library if gem is installed and loaded + require 'casclient/frameworks/rails/filter' + before_filter CASClient::Frameworks::Rails::GatewayFilter, :only => :login - # This requires the user to be authenticated for viewing all other pages. - before_filter CASClient::Frameworks::Rails::Filter, :except => [:login , :calendar] + # This requires the user to be authenticated for viewing all other pages. + before_filter CASClient::Frameworks::Rails::Filter, :except => [:login , :calendar] + end end before_filter :set_session_expiration before_filter :set_time_zone diff --git a/config/environment.rb b/config/environment.rb index 772b0232..221f8daf 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -65,9 +65,7 @@ Rails::Initializer.run do |config| # See Rails::Configuration for more options if ( SITE_CONFIG['authentication_schemes'].include? 'cas') #requires rubycas-client gem to be installed - config.gem "rubycas-client" - require 'casclient' - require 'casclient/frameworks/rails/filter' + config.gem "rubycas-client", :lib => 'casclient' end end @@ -106,10 +104,13 @@ end if ( SITE_CONFIG['authentication_schemes'].include? 'cas') #requires rubycas-client gem to be installed - CASClient::Frameworks::Rails::Filter.configure( - :cas_base_url => SITE_CONFIG['cas_server'] , - :cas_server_logout => SITE_CONFIG['cas_server_logout'] - ) + if (CASClient rescue nil) + require 'casclient/frameworks/rails/filter' + CASClient::Frameworks::Rails::Filter.configure( + :cas_base_url => SITE_CONFIG['cas_server'] , + :cas_server_logout => SITE_CONFIG['cas_server_logout'] + ) + end end tracks_version='1.8devel'