Module: DeviseCasAuthenticatable::SingleSignOut::DestroySession

Included in:
Devise::CasSessionsController
Defined in:
lib/devise_cas_authenticatable/single_sign_out.rb

Overview

Supports destroying sessions by ID for ActiveRecord and Redis session stores

Instance Method Summary collapse

Instance Method Details

#current_session_storeObject



44
45
46
# File 'lib/devise_cas_authenticatable/single_sign_out.rb', line 44

def current_session_store
  session_store_identifier.current_session_store
end

#destroy_session_by_id(sid) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/devise_cas_authenticatable/single_sign_out.rb', line 10

def destroy_session_by_id(sid)
  logger.debug "Single Sign Out from session store: #{current_session_store.class}"

  if session_store_class.name =~ /ActiveRecord::SessionStore/
    session = session_store_class::Session.find_by_session_id(sid)
    session.destroy if session
    true
  elsif session_store_class.name =~ /ActionDispatch::Session::ActiveRecordStore/
    session = current_session_store.session_class.find_by_session_id(sid)
    session.destroy if session
    true
  elsif session_store_class.name =~ /ActionDispatch::Session::DalliStore/
    current_session_store.send(:destroy_session, env, sid, drop: true)
    true
  elsif session_store_class.name =~ /RedisSessionStore/
    current_session_store.send(:destroy_session, env, sid, drop: true)
    true
  elsif session_store_class.name =~ /Redis/
    current_session_store.instance_variable_get(:@pool).del(sid)
    true
  elsif session_store_class.name =~ /CacheStore/
    current_session_store.destroy_session({}, sid, {})
    true
  else
    logger.error "Cannot process logout request because this Rails application's session store is "+
          " #{session_store_class.name} and is not a support session store type for Single Sign-Out."
    false
  end
end

#session_store_classObject



48
49
50
# File 'lib/devise_cas_authenticatable/single_sign_out.rb', line 48

def session_store_class
  session_store_identifier.session_store_class
end

#session_store_identifierObject



40
41
42
# File 'lib/devise_cas_authenticatable/single_sign_out.rb', line 40

def session_store_identifier
  @session_store_identifier ||= DeviseCasAuthenticatable::SessionStoreIdentifier.new
end