devise_cas_authenticatable 1.10.4 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +32 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +65 -44
- data/Gemfile +8 -0
- data/README.md +85 -89
- data/app/controllers/devise/cas_sessions_controller.rb +25 -69
- data/app/views/devise/cas_sessions/unregistered.html.erb +3 -3
- data/devise_cas_authenticatable.gemspec +19 -26
- data/lib/devise_cas_authenticatable/model.rb +21 -28
- data/lib/devise_cas_authenticatable/routes.rb +22 -44
- data/lib/devise_cas_authenticatable/strategy.rb +14 -30
- data/lib/devise_cas_authenticatable.rb +27 -79
- data/spec/model_spec.rb +29 -35
- data/spec/routes_spec.rb +26 -26
- data/spec/scenario/app/assets/config/manifest.js +0 -0
- data/spec/scenario/app/controllers/home_controller.rb +2 -2
- data/spec/scenario/app/views/layouts/application.html.erb +1 -3
- data/spec/scenario/config/application.rb +1 -27
- data/spec/scenario/config/initializers/backtrace_silencers.rb +1 -1
- data/spec/scenario/config/initializers/devise.rb +2 -2
- data/spec/scenario/config/routes.rb +0 -4
- data/spec/scenario/db/migrate/20100401102949_create_tables.rb +3 -3
- data/spec/scenario/db/migrate/20111002012903_add_sessions_table.rb +1 -1
- data/spec/scenario/db/migrate/20121009092400_add_deactivated_flag_to_users.rb +1 -1
- data/spec/spec_helper.rb +38 -8
- data/spec/strategy_spec.rb +43 -82
- data/spec/support/migrations.rb +1 -1
- metadata +21 -126
- data/.travis.yml +0 -45
- data/Gemfile.devise12 +0 -11
- data/Gemfile.devise13 +0 -11
- data/Gemfile.devise14 +0 -11
- data/Gemfile.devise15 +0 -11
- data/Gemfile.devise20 +0 -11
- data/Gemfile.devise21 +0 -13
- data/Gemfile.devise30 +0 -12
- data/Gemfile.devise42 +0 -13
- data/lib/devise_cas_authenticatable/exceptions.rb +0 -10
- data/lib/devise_cas_authenticatable/memcache_checker.rb +0 -42
- data/lib/devise_cas_authenticatable/railtie.rb +0 -14
- data/lib/devise_cas_authenticatable/schema.rb +0 -20
- data/lib/devise_cas_authenticatable/session_store_identifier.rb +0 -29
- data/lib/devise_cas_authenticatable/single_sign_out/rack.rb +0 -39
- data/lib/devise_cas_authenticatable/single_sign_out/strategies/base.rb +0 -11
- data/lib/devise_cas_authenticatable/single_sign_out/strategies/rails_cache.rb +0 -31
- data/lib/devise_cas_authenticatable/single_sign_out/strategies/redis_cache.rb +0 -38
- data/lib/devise_cas_authenticatable/single_sign_out/strategies.rb +0 -58
- data/lib/devise_cas_authenticatable/single_sign_out/warden_failure_app.rb +0 -46
- data/lib/devise_cas_authenticatable/single_sign_out/with_conn.rb +0 -14
- data/lib/devise_cas_authenticatable/single_sign_out.rb +0 -69
- data/spec/config_spec.rb +0 -27
- data/spec/memcache_checker_spec.rb +0 -49
- data/spec/scenario/config/castronaut.yml +0 -32
- data/spec/scenario/config/initializers/castronaut.rb +0 -1
- data/spec/scenario/config/initializers/session_store.rb +0 -8
- data/spec/single_sign_out_spec.rb +0 -51
- data/spec/support/urls.rb +0 -19
- data/spec/warden_failure_app_spec.rb +0 -53
data/Gemfile.devise13
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 3.1.0'
|
7
|
-
gem 'devise', '~> 1.3.0'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
11
|
-
end
|
data/Gemfile.devise14
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 3.2.0'
|
7
|
-
gem 'devise', '~> 1.4.0'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
11
|
-
end
|
data/Gemfile.devise15
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 3.2.0'
|
7
|
-
gem 'devise', '~> 1.5.0'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
11
|
-
end
|
data/Gemfile.devise20
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 3.2.0'
|
7
|
-
gem 'devise', '~> 2.0.0'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
11
|
-
end
|
data/Gemfile.devise21
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 3.2.0'
|
7
|
-
gem 'devise', '~> 2.1.0'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
11
|
-
gem 'minitest'
|
12
|
-
gem 'test-unit'
|
13
|
-
end
|
data/Gemfile.devise30
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 4.0.0'
|
7
|
-
gem 'devise', '~> 3.0.0'
|
8
|
-
gem 'activerecord-session_store'
|
9
|
-
|
10
|
-
group :test do
|
11
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
12
|
-
end
|
data/Gemfile.devise42
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in devise_cas_authenticatable.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rails', '~> 5.0.0'
|
7
|
-
gem 'devise', '~> 4.2.0'
|
8
|
-
gem 'activerecord-session_store'
|
9
|
-
gem 'sinatra', '~> 2.0.0.beta2'
|
10
|
-
|
11
|
-
group :test do
|
12
|
-
gem 'castronaut', :git => 'https://github.com/nbudin/castronaut.git', :branch => 'dam5s-merge'
|
13
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
require 'timeout'
|
3
|
-
|
4
|
-
module DeviseCasAuthenticatable
|
5
|
-
class MemcacheChecker
|
6
|
-
attr_reader :rails_configuration
|
7
|
-
|
8
|
-
def initialize(rails_configuration)
|
9
|
-
@rails_configuration = rails_configuration
|
10
|
-
end
|
11
|
-
|
12
|
-
def session_store_memcache?
|
13
|
-
!!(session_store_class.name =~ /memcache/i)
|
14
|
-
end
|
15
|
-
|
16
|
-
def alive?
|
17
|
-
memcache_servers = rails_configuration.session_options[:memcache_server] || ["127.0.0.1:11211"]
|
18
|
-
memcache_servers.each do |server|
|
19
|
-
host, port = server.split(":")
|
20
|
-
begin
|
21
|
-
try_connect host, port
|
22
|
-
|
23
|
-
return true
|
24
|
-
rescue Errno::ECONNREFUSED, Timeout::Error
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def try_connect(host, port)
|
31
|
-
Timeout::timeout(1) do
|
32
|
-
TCPSocket.open(host, port)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def session_store_class
|
39
|
-
@session_store_class ||= DeviseCasAuthenticatable::SessionStoreIdentifier.new.session_store_class
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'devise_cas_authenticatable'
|
2
|
-
require 'rails'
|
3
|
-
|
4
|
-
module DeviseCasAuthenticatable
|
5
|
-
class Railtie < ::Rails::Railtie
|
6
|
-
initializer "devise_cas_authenticatable.use_rack_middleware" do |app|
|
7
|
-
if Rails::VERSION::MAJOR < 5
|
8
|
-
app.config.middleware.use "DeviseCasAuthenticatable::SingleSignOut::StoreSessionId"
|
9
|
-
else
|
10
|
-
app.config.middleware.use DeviseCasAuthenticatable::SingleSignOut::StoreSessionId
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'devise/version'
|
2
|
-
|
3
|
-
# Devise 2.1 removes schema stuff
|
4
|
-
if Devise::VERSION < "2.1"
|
5
|
-
require 'devise/schema'
|
6
|
-
|
7
|
-
module Devise
|
8
|
-
module Schema
|
9
|
-
# Adds the required fields for cas_authenticatable to the schema. Currently
|
10
|
-
# this is just username (String).
|
11
|
-
def cas_authenticatable
|
12
|
-
if respond_to? :apply_devise_schema
|
13
|
-
apply_devise_schema :username, String
|
14
|
-
else
|
15
|
-
apply_schema :username, String
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module DeviseCasAuthenticatable
|
2
|
-
class SessionStoreIdentifier
|
3
|
-
|
4
|
-
def current_session_store
|
5
|
-
app = Rails.application.app
|
6
|
-
begin
|
7
|
-
app = (app.instance_variable_get(:@backend) || app.instance_variable_get(:@app) || app.instance_variable_get(:@target))
|
8
|
-
end until app.nil? or app.class == session_store_class
|
9
|
-
app
|
10
|
-
end
|
11
|
-
|
12
|
-
def session_store_class
|
13
|
-
@session_store_class ||=
|
14
|
-
begin
|
15
|
-
# Rails 3 & 4 session store
|
16
|
-
if ::DeviseCasAuthenticatable::SingleSignOut.rails3_or_greater?
|
17
|
-
Rails.configuration.session_store
|
18
|
-
::Rails.application.config.session_store
|
19
|
-
else
|
20
|
-
# => Rails 2
|
21
|
-
ActionController::Base.session_store
|
22
|
-
end
|
23
|
-
rescue NameError => e
|
24
|
-
# for older versions of Rails (prior to 2.3)
|
25
|
-
ActionController::Base.session_options[:database_manager]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module DeviseCasAuthenticatable
|
2
|
-
module SingleSignOut
|
3
|
-
|
4
|
-
class StoreSessionId
|
5
|
-
CAS_TICKET_STORE = 'cas_last_valid_ticket_store'
|
6
|
-
CAS_LAST_TICKET = 'cas_last_valid_ticket'
|
7
|
-
|
8
|
-
def initialize(app)
|
9
|
-
@app = app
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
store_session_id_for_cas_ticket(env)
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
def store_session_id_for_cas_ticket(env)
|
19
|
-
request = Rack::Request.new(env)
|
20
|
-
session = request.session
|
21
|
-
|
22
|
-
if session.respond_to?(:id)
|
23
|
-
# Rack > 1.5
|
24
|
-
session_id = session.id
|
25
|
-
else
|
26
|
-
# Compatible with old Rack requests
|
27
|
-
session_id = env['rack.session.options'][:id]
|
28
|
-
end
|
29
|
-
cas_ticket_store = session[CAS_TICKET_STORE]
|
30
|
-
|
31
|
-
if cas_ticket_store
|
32
|
-
Rails.logger.info "Storing Session ID #{session_id} for ticket #{session[CAS_LAST_TICKET]}"
|
33
|
-
::DeviseCasAuthenticatable::SingleSignOut::Strategies.current_strategy.store_session_id_for_index(session[CAS_LAST_TICKET], session_id)
|
34
|
-
session[CAS_TICKET_STORE] = false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module DeviseCasAuthenticatable
|
2
|
-
module SingleSignOut
|
3
|
-
module Strategies
|
4
|
-
class RailsCache < Base
|
5
|
-
def store_session_id_for_index(session_index, session_id)
|
6
|
-
logger.debug("Storing #{session_id} for index #{session_index}")
|
7
|
-
Rails.cache.write(cache_key(session_index), session_id)
|
8
|
-
end
|
9
|
-
|
10
|
-
def find_session_id_by_index(session_index)
|
11
|
-
sid = Rails.cache.read(cache_key(session_index))
|
12
|
-
logger.debug("Found session id #{sid} for index #{session_index}")
|
13
|
-
sid
|
14
|
-
end
|
15
|
-
|
16
|
-
def delete_session_index(session_index)
|
17
|
-
logger.debug("Deleting index #{session_index}")
|
18
|
-
Rails.cache.delete(cache_key(session_index))
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def cache_key(session_index)
|
24
|
-
"devise_cas_authenticatable:#{session_index}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
::DeviseCasAuthenticatable::SingleSignOut::Strategies.add( :rails_cache, DeviseCasAuthenticatable::SingleSignOut::Strategies::RailsCache )
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'devise_cas_authenticatable/single_sign_out/with_conn'
|
2
|
-
|
3
|
-
module DeviseCasAuthenticatable
|
4
|
-
module SingleSignOut
|
5
|
-
module Strategies
|
6
|
-
class RedisCache < Base
|
7
|
-
include ::DeviseCasAuthenticatable::SingleSignOut::DestroySession
|
8
|
-
include ::DeviseCasAuthenticatable::SingleSignOut::WithConn
|
9
|
-
|
10
|
-
def store_session_id_for_index(session_index, session_id)
|
11
|
-
logger.debug("Storing #{session_id} for index #{session_index}")
|
12
|
-
with_conn do |conn|
|
13
|
-
conn.set(
|
14
|
-
cache_key(session_index),
|
15
|
-
session_id
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
def find_session_id_by_index(session_index)
|
20
|
-
sid = with_conn { |conn| conn.get(cache_key(session_index)) }
|
21
|
-
logger.debug("Found session id #{sid} for index #{session_index}") if sid
|
22
|
-
sid
|
23
|
-
end
|
24
|
-
def delete_session_index(session_index)
|
25
|
-
logger.debug("Deleting index #{session_index}")
|
26
|
-
destroy_session_by_id(session_index)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
def cache_key(session_index)
|
31
|
-
"devise_cas_authenticatable:#{session_index}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
::DeviseCasAuthenticatable::SingleSignOut::Strategies.add(:redis_cache, DeviseCasAuthenticatable::SingleSignOut::Strategies::RedisCache )
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module DeviseCasAuthenticatable
|
2
|
-
module SingleSignOut
|
3
|
-
module Strategies
|
4
|
-
class << self
|
5
|
-
|
6
|
-
# Add a strategy and store it in a hash.
|
7
|
-
def add(label, strategy, &block)
|
8
|
-
strategy ||= Class.new(DeviseCasAuthenticatable::SingleSignOut::Strategies::Base)
|
9
|
-
strategy.class_eval(&block) if block_given?
|
10
|
-
|
11
|
-
check_method(label, strategy, :store_session_id_for_index)
|
12
|
-
check_method(label, strategy, :find_session_id_by_index)
|
13
|
-
check_method(label, strategy, :delete_session_index)
|
14
|
-
|
15
|
-
unless strategy.ancestors.include?(DeviseCasAuthenticatable::SingleSignOut::Strategies::Base)
|
16
|
-
raise "#{label.inspect} is not a #{base}"
|
17
|
-
end
|
18
|
-
|
19
|
-
_strategies[label] = strategy.new()
|
20
|
-
end
|
21
|
-
|
22
|
-
# Update a previously given strategy.
|
23
|
-
def update(label, &block)
|
24
|
-
strategy = _strategies[label]
|
25
|
-
raise "Unknown strategy #{label.inspect}" unless strategy
|
26
|
-
add(label, strategy, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Provides access to strategies by label
|
30
|
-
def [](label)
|
31
|
-
_strategies[label]
|
32
|
-
end
|
33
|
-
|
34
|
-
def current_strategy
|
35
|
-
self[::Devise.cas_single_sign_out_mapping_strategy]
|
36
|
-
end
|
37
|
-
|
38
|
-
# Clears all declared.
|
39
|
-
def clear!
|
40
|
-
_strategies.clear
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def _strategies
|
46
|
-
@strategies ||= {}
|
47
|
-
end
|
48
|
-
|
49
|
-
def check_method(label, strategy, method)
|
50
|
-
unless strategy.method_defined?(method)
|
51
|
-
raise NoMethodError, "#{method.to_s} is not declared in the #{label.inspect} strategy"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# Redirect to the logout url when :warden is thrown,
|
2
|
-
# so that a single_sign_out request can be initiated
|
3
|
-
class DeviseCasAuthenticatable::SingleSignOut::WardenFailureApp < Devise::FailureApp
|
4
|
-
|
5
|
-
# You need to override respond to eliminate recall
|
6
|
-
def respond
|
7
|
-
if http_auth?
|
8
|
-
http_auth
|
9
|
-
else
|
10
|
-
redirect
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def redirect
|
15
|
-
store_location!
|
16
|
-
if flash[:timedout] && flash[:alert]
|
17
|
-
flash.keep(:timedout)
|
18
|
-
flash.keep(:alert)
|
19
|
-
else
|
20
|
-
flash[:alert] = i18n_message
|
21
|
-
end
|
22
|
-
redirect_to redirect_url
|
23
|
-
end
|
24
|
-
|
25
|
-
protected
|
26
|
-
|
27
|
-
def redirect_url
|
28
|
-
if [:timeout, :inactive].include? warden_message
|
29
|
-
flash[:timedout] = true if warden_message == :timeout
|
30
|
-
Devise.cas_client.logout_url
|
31
|
-
else
|
32
|
-
if respond_to?(:scope_path)
|
33
|
-
scope_path
|
34
|
-
else
|
35
|
-
super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Devise < 2.0 doesn't have this method, which we want to use
|
41
|
-
unless instance_methods.include?(:warden_message)
|
42
|
-
define_method :warden_message do
|
43
|
-
@message ||= warden.message || warden_options[:message]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module DeviseCasAuthenticatable
|
2
|
-
module SingleSignOut
|
3
|
-
module WithConn
|
4
|
-
def with_conn(&block)
|
5
|
-
if old_style_conn = current_session_store.instance_variable_get(:@pool)
|
6
|
-
yield old_style_conn
|
7
|
-
else
|
8
|
-
current_session_store.instance_variable_get(:@conn)
|
9
|
-
.instance_variable_get(:@pool).with &block
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'devise_cas_authenticatable/single_sign_out/with_conn'
|
2
|
-
|
3
|
-
module DeviseCasAuthenticatable
|
4
|
-
module SingleSignOut
|
5
|
-
|
6
|
-
def self.rails3_or_greater?
|
7
|
-
defined?(::Rails) && ::Rails::VERSION::MAJOR >= 3
|
8
|
-
end
|
9
|
-
|
10
|
-
# Supports destroying sessions by ID for ActiveRecord and Redis session stores
|
11
|
-
module DestroySession
|
12
|
-
include ::DeviseCasAuthenticatable::SingleSignOut::WithConn
|
13
|
-
|
14
|
-
def destroy_session_by_id(sid)
|
15
|
-
logger.debug "Single Sign Out from session store: #{current_session_store.class}"
|
16
|
-
|
17
|
-
if session_store_class.name =~ /ActiveRecord::SessionStore/
|
18
|
-
session = session_store_class::Session.find_by_session_id(sid)
|
19
|
-
session.destroy if session
|
20
|
-
true
|
21
|
-
elsif session_store_class.name =~ /ActionDispatch::Session::ActiveRecordStore/
|
22
|
-
session = current_session_store.session_class.find_by_session_id(sid)
|
23
|
-
session.destroy if session
|
24
|
-
true
|
25
|
-
elsif session_store_class.name =~ /ActionDispatch::Session::DalliStore/
|
26
|
-
current_session_store.send(:destroy_session, env, sid, drop: true)
|
27
|
-
true
|
28
|
-
elsif session_store_class.name =~ /RedisSessionStore/
|
29
|
-
current_session_store.send(:destroy_session, env, sid, drop: true)
|
30
|
-
true
|
31
|
-
elsif session_store_class.name =~ /Redis/
|
32
|
-
with_conn { |conn| conn.del(sid) }
|
33
|
-
true
|
34
|
-
elsif session_store_class.name =~ /CacheStore/
|
35
|
-
if current_session_store.respond_to?(:delete_session) # Rails 5 and up
|
36
|
-
current_session_store.delete_session({}, sid, {})
|
37
|
-
else
|
38
|
-
current_session_store.destroy_session({}, sid, {})
|
39
|
-
end
|
40
|
-
|
41
|
-
true
|
42
|
-
else
|
43
|
-
logger.error "Cannot process logout request because this Rails application's session store is "+
|
44
|
-
" #{session_store_class.name} and is not a support session store type for Single Sign-Out."
|
45
|
-
false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def session_store_identifier
|
50
|
-
@session_store_identifier ||= DeviseCasAuthenticatable::SessionStoreIdentifier.new
|
51
|
-
end
|
52
|
-
|
53
|
-
def current_session_store
|
54
|
-
session_store_identifier.current_session_store
|
55
|
-
end
|
56
|
-
|
57
|
-
def session_store_class
|
58
|
-
session_store_identifier.session_store_class
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
require 'devise_cas_authenticatable/single_sign_out/strategies'
|
66
|
-
require 'devise_cas_authenticatable/single_sign_out/strategies/base'
|
67
|
-
require 'devise_cas_authenticatable/single_sign_out/strategies/rails_cache'
|
68
|
-
require 'devise_cas_authenticatable/single_sign_out/strategies/redis_cache'
|
69
|
-
require 'devise_cas_authenticatable/single_sign_out/rack'
|
data/spec/config_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Devise
|
4
|
-
def self.reset_cas_client!
|
5
|
-
@@cas_client = nil
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Devise do
|
10
|
-
before do
|
11
|
-
Devise.cas_base_url = "http://www.example.com/cas_server"
|
12
|
-
end
|
13
|
-
|
14
|
-
after { Devise.reset_cas_client! }
|
15
|
-
|
16
|
-
it "should figure out the base URL correctly" do
|
17
|
-
Devise.cas_client.cas_base_url.should == "http://www.example.com/cas_server"
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should accept extra options for the CAS client object' do
|
21
|
-
Devise.cas_client_config_options = { :encode_extra_attributes_as => :json }
|
22
|
-
|
23
|
-
conf_options = Devise.cas_client.instance_variable_get(:@conf_options)
|
24
|
-
conf_options.should_not be_nil
|
25
|
-
conf_options[:encode_extra_attributes_as].should == :json
|
26
|
-
end
|
27
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe DeviseCasAuthenticatable::MemcacheChecker do
|
4
|
-
let(:conf_double) { stub(session_options: {}) }
|
5
|
-
|
6
|
-
describe '#session_store_memcache?' do
|
7
|
-
subject(:session_store_memcache?) { described_class.new(conf_double).session_store_memcache? }
|
8
|
-
|
9
|
-
before do
|
10
|
-
DeviseCasAuthenticatable::SessionStoreIdentifier.any_instance
|
11
|
-
.stubs(:session_store_class).returns(session_store_class)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when session store is memcache" do
|
15
|
-
let(:session_store_class) { FakeMemcacheStore }
|
16
|
-
|
17
|
-
it { expect(session_store_memcache?).to eq true }
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when session store is NOT memcache" do
|
21
|
-
let(:session_store_class) { String }
|
22
|
-
|
23
|
-
it { expect(session_store_memcache?).to eq false }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'alive?' do
|
28
|
-
context "when memcache is down" do
|
29
|
-
let(:conf_double) { stub(session_options: {memcache_server: ['127.0.0.1:11223']}) }
|
30
|
-
subject(:alive?) { described_class.new(conf_double).alive? }
|
31
|
-
|
32
|
-
it { expect(alive?).to eq false }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when memcache is running" do
|
36
|
-
let(:conf_double) { stub(session_options: {memcache_server: ['127.0.0.1:11214']}) }
|
37
|
-
subject(:alive?) { described_class.new(conf_double).alive? }
|
38
|
-
|
39
|
-
before do
|
40
|
-
DeviseCasAuthenticatable::MemcacheChecker.any_instance.stubs(:try_connect)
|
41
|
-
end
|
42
|
-
|
43
|
-
it { expect(alive?).to eq true }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class FakeMemcacheStore
|
49
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
organization_name: Foo Bar Baz Industries, LLC Inc. A division of Holdings Co.
|
2
|
-
|
3
|
-
environment: development
|
4
|
-
# The port the CAS webserver will start on
|
5
|
-
server_port: 4567
|
6
|
-
|
7
|
-
log_directory: log
|
8
|
-
|
9
|
-
log_level: Logger::DEBUG
|
10
|
-
|
11
|
-
ssl_enabled: false
|
12
|
-
|
13
|
-
cas_database:
|
14
|
-
adapter: sqlite3
|
15
|
-
database: db/cas.sqlite3
|
16
|
-
timeout: 5000
|
17
|
-
|
18
|
-
cas_adapter:
|
19
|
-
adapter: test_adapter
|
20
|
-
|
21
|
-
# Use this example if you are using LDAP as your authentication source
|
22
|
-
# cas_adapter:
|
23
|
-
# adapter: ldap
|
24
|
-
# host: localhost
|
25
|
-
# port: 389
|
26
|
-
# prefix: cn=
|
27
|
-
# base: dc=example, dc=com
|
28
|
-
|
29
|
-
# Uncomment these to enable authentication callbacks
|
30
|
-
# callbacks:
|
31
|
-
# on_authentication_success: http://example.com/authentication/success
|
32
|
-
# on_authentication_failed: http://example.com/authentication/failed
|
@@ -1 +0,0 @@
|
|
1
|
-
Castronaut.config.connect_activerecord
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Scenario::Application.config.session_store :cookie_store, :key => '_scenario_session'
|
4
|
-
|
5
|
-
# Use the database for sessions instead of the cookie-based default,
|
6
|
-
# which shouldn't be used to store highly confidential information
|
7
|
-
# (create the session table with "rake db:sessions:create")
|
8
|
-
Scenario::Application.config.session_store :active_record_store
|