This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Using CAS
Machiste N. Quintana edited this page Jan 12, 2015
·
10 revisions
Also check out: https://gist.github.com/baygross/2054898
#authentication
gem 'rubycas-client-rails'
gem 'rubycas-client', '2.2.1'
In application_controller.rb:
before_filter CASClient::Frameworks::Rails::Filter, :unless => :skip_login?
before_filter :current_user
#so we can use current_user in the views
helper_method :current_user
def current_user
current_user = User.find_or_create_by( netid: session[:cas_user] )
if !current_user
redirect_to :root
return false
end
end
# hack for skip_before_filter with CAS
# overwrite this method (with 'true') in any controller you want to skip CAS authentication
def skip_login?
false
end
In config/environment.rb
CASClient::Frameworks::Rails::Filter.configure(
:cas_base_url => "https://secure.its.yale.edu/cas/",
:username_session_key => :cas_user,
:extra_attributes_session_key => :cas_extra_attributes
)
#Rails 4
As of Aug 23, 2014 rubycas-client
hasn't yet been updated to work with Rails 4 in the RubyGems repository, but it works straight from GitHub!
gem 'rubycas-client', :git => "https://github.com/rubycas/rubycas-client"
You don't need to include gem 'rubycas-client-rails'