Skip to content

Compatibility with activerecord-session_store #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions lib/rubycas-client-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,18 @@ def single_sign_out(controller)
## required_sess_store = CGI::Session::ActiveRecordStore
## current_sess_store = ActionController::Base.session_options[:database_manager]

# Rails 3.0
required_sess_store = ActiveRecord::SessionStore
current_sess_store = ::Rails.application.config.session_store
# Rails 3.0 through 4.2, including activerecord-session_store gem
required_sess_store = [ActiveRecord::SessionStore]
# activerecord-session_store support
required_sess_store << ActionDispatch::Session::ActiveRecordStore if defined? ActionDispatch::Session::ActiveRecordStore
current_sess_store = ::Rails.application.config.session_store
session_store = current_sess_store == ActiveRecord::SessionStore ? ActiveRecord::SessionStore::Session : current_sess_store.session_class

if current_sess_store == required_sess_store
if required_sess_store.include? current_sess_store
session_id = read_service_session_lookup(si)

if session_id
session = current_sess_store::Session.find_by_session_id(session_id)
session = session_store.find_by_session_id(session_id)
if session
st = session.data[:cas_last_valid_ticket] || si
delete_service_session_lookup(st) if st
Expand All @@ -333,8 +336,8 @@ def single_sign_out(controller)
end
else
log.error "Cannot process logout request because this Rails application's session store is "+
" #{current_sess_store.name.inspect}. Single Sign-Out only works with the "+
" #{required_sess_store.name.inspect} session store."
"#{current_sess_store.name.inspect}. Single Sign-Out only works with the "+
"#{required_sess_store.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')} session store."
end

# Return true to indicate that a single-sign-out request was detected
Expand Down