Skip to content
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

Minor fixes of Single Sign Out #1

Open
wants to merge 3 commits into
base: single_sign_out_filter
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
22 changes: 18 additions & 4 deletions lib/devise_cas_authenticatable/single_sign_out.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def session_store_class
end

def current_session_store
app = Rails.application.app
app = get_first_middleware_app
begin
app = app.instance_variable_get :@app
end until app.nil? or app.class == session_store_class
Expand All @@ -36,15 +36,29 @@ def destroy_session_by_id(sid)
session = current_session_store::Session.find_by_session_id(sid)
session.destroy if session
true
elsif session_store_class.name =~ /RedisSessionStore/
elsif session_store_class.name =~ /Redis.*Store/
current_session_store.instance_variable_get(:@pool).del(sid)
true
else
log.error "Cannot process logout request because this Rails application's session store is "+
" #{current_session_store.name.inspect} and is not a support session store type for Single Sign-Out."
::Rails.logger.error "Cannot process logout request because this Rails application's session store is "+
" #{current_session_store.class.to_s} and is not a support session store type for Single Sign-Out."
false
end
end

private

def get_first_middleware_app
# For case of running in production mode.
@first_middleware_app ||= if defined?(Rack::Cache::Context) && Rails.application.app.class == Rack::Cache::Context
Rails.application.app.
entitystore.instance_variable_get(:@store).
instance_variable_get(:@middleware).instance_variable_get(:@app)
else
Rails.application.app
end

end
end

end
Expand Down