casino 1.3.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +3 -0
- data/.travis.yml +1 -1
- data/README.md +1 -8
- data/Rakefile +0 -2
- data/app/assets/javascripts/casino/application.js +1 -0
- data/app/assets/javascripts/casino/index.js +0 -2
- data/app/assets/javascripts/casino/sessions.js +32 -0
- data/app/authenticators/casino/static_authenticator.rb +23 -0
- data/app/builders/casino/ticket_validation_response_builder.rb +84 -0
- data/app/controllers/casino/api/v1/tickets_controller.rb +7 -4
- data/app/controllers/casino/application_controller.rb +2 -3
- data/{lib/casino/listener/legacy_validator.rb → app/listeners/casino/legacy_validator_listener.rb} +2 -2
- data/app/listeners/casino/listener.rb +16 -0
- data/{lib/casino/listener/login_credential_acceptor.rb → app/listeners/casino/login_credential_acceptor_listener.rb} +2 -2
- data/{lib/casino/listener/login_credential_requestor.rb → app/listeners/casino/login_credential_requestor_listener.rb} +2 -2
- data/{lib/casino/listener/logout.rb → app/listeners/casino/logout_listener.rb} +2 -2
- data/{lib/casino/listener/other_sessions_destroyer.rb → app/listeners/casino/other_sessions_destroyer_listener.rb} +2 -2
- data/{lib/casino/listener/proxy_ticket_provider.rb → app/listeners/casino/proxy_ticket_provider_listener.rb} +2 -2
- data/{lib/casino/listener/second_factor_authentication_acceptor.rb → app/listeners/casino/second_factor_authentication_acceptor_listener.rb} +2 -2
- data/{lib/casino/listener/session_destroyer.rb → app/listeners/casino/session_destroyer_listener.rb} +2 -2
- data/{lib/casino/listener/session_overview.rb → app/listeners/casino/session_overview_listener.rb} +2 -2
- data/{lib/casino/listener/ticket_validator.rb → app/listeners/casino/ticket_validator_listener.rb} +2 -2
- data/{lib/casino/listener/two_factor_authenticator_activator.rb → app/listeners/casino/two_factor_authenticator_activator_listener.rb} +2 -2
- data/{lib/casino/listener/two_factor_authenticator_destroyer.rb → app/listeners/casino/two_factor_authenticator_destroyer_listener.rb} +2 -2
- data/{lib/casino/listener/two_factor_authenticator_overview.rb → app/listeners/casino/two_factor_authenticator_overview_listener.rb} +2 -2
- data/{lib/casino/listener/two_factor_authenticator_registrator.rb → app/listeners/casino/two_factor_authenticator_registrator_listener.rb} +2 -2
- data/app/models/casino/login_ticket.rb +12 -0
- data/app/models/casino/proxy_granting_ticket.rb +8 -0
- data/app/models/casino/proxy_ticket.rb +25 -0
- data/app/models/casino/service_rule.rb +27 -0
- data/app/models/casino/service_ticket.rb +43 -0
- data/app/models/casino/service_ticket/single_sign_out_notifier.rb +44 -0
- data/app/models/casino/ticket_granting_ticket.rb +57 -0
- data/app/models/casino/two_factor_authenticator.rb +18 -0
- data/app/models/casino/user.rb +12 -0
- data/app/models/casino/validation_result.rb +5 -0
- data/app/processors/casino/api/login_credential_acceptor_processor.rb +46 -0
- data/app/processors/casino/api/logout_processor.rb +17 -0
- data/app/processors/casino/api/service_ticket_provider_processor.rb +69 -0
- data/app/processors/casino/legacy_validator_processor.rb +19 -0
- data/app/processors/casino/login_credential_acceptor_processor.rb +63 -0
- data/app/processors/casino/login_credential_requestor_processor.rb +66 -0
- data/app/processors/casino/logout_processor.rb +23 -0
- data/app/processors/casino/other_sessions_destroyer_processor.rb +26 -0
- data/app/processors/casino/processor.rb +5 -0
- data/app/processors/casino/processor_concern/authentication.rb +87 -0
- data/app/processors/casino/processor_concern/browser.rb +14 -0
- data/app/processors/casino/processor_concern/login_tickets.rb +28 -0
- data/app/processors/casino/processor_concern/proxy_granting_tickets.rb +43 -0
- data/app/processors/casino/processor_concern/proxy_tickets.rb +56 -0
- data/app/processors/casino/processor_concern/service_tickets.rb +50 -0
- data/app/processors/casino/processor_concern/ticket_granting_tickets.rb +65 -0
- data/app/processors/casino/processor_concern/tickets.rb +17 -0
- data/app/processors/casino/processor_concern/two_factor_authenticators.rb +22 -0
- data/app/processors/casino/proxy_ticket_provider_processor.rb +41 -0
- data/app/processors/casino/proxy_ticket_validator_processor.rb +22 -0
- data/app/processors/casino/second_factor_authentication_acceptor_processor.rb +45 -0
- data/app/processors/casino/service_ticket_validator_processor.rb +46 -0
- data/app/processors/casino/session_destroyer_processor.rb +25 -0
- data/app/processors/casino/session_overview_processor.rb +21 -0
- data/app/processors/casino/two_factor_authenticator_activator_processor.rb +41 -0
- data/app/processors/casino/two_factor_authenticator_destroyer_processor.rb +33 -0
- data/app/processors/casino/two_factor_authenticator_overview_processor.rb +20 -0
- data/app/processors/casino/two_factor_authenticator_registrator_processor.rb +24 -0
- data/app/views/casino/application/_footer.html.erb +1 -1
- data/app/views/casino/sessions/new.html.erb +2 -1
- data/app/views/casino/sessions/validate_otp.html.erb +1 -1
- data/app/views/casino/two_factor_authenticators/new.html.erb +2 -2
- data/app/views/layouts/application.html.erb +1 -1
- data/casino.gemspec +9 -4
- data/db/migrate/20130809135400_create_core_schema.rb +117 -0
- data/db/migrate/20130809135401_rename_base_models.rb +101 -0
- data/db/migrate/20131022110146_cleanup_indexes.rb +27 -0
- data/db/migrate/20131022110246_fix_long_index_names.rb +12 -0
- data/db/migrate/20131022110346_change_service_to_text.rb +6 -0
- data/lib/casino.rb +47 -3
- data/lib/casino/authenticator.rb +9 -0
- data/lib/casino/engine.rb +26 -0
- data/lib/casino/inflections.rb +7 -0
- data/lib/casino/tasks.rb +1 -0
- data/lib/casino/tasks/cleanup.rake +59 -0
- data/lib/casino/tasks/service_rule.rake +49 -0
- data/lib/casino/version.rb +1 -1
- data/lib/generators/casino/install/USAGE +13 -0
- data/lib/generators/casino/install/install_generator.rb +47 -0
- data/lib/generators/casino/{templates → install/templates}/README +3 -4
- data/lib/generators/casino/{templates → install/templates}/cas.yml +2 -2
- data/lib/generators/casino/{templates → install/templates}/casino_and_overrides.scss +0 -0
- data/lib/generators/casino/templates/casino_core.rb +1 -1
- data/spec/authenticator/base_spec.rb +13 -0
- data/spec/authenticator/static_spec.rb +42 -0
- data/spec/controllers/api/v1/tickets_controller_spec.rb +15 -15
- data/spec/controllers/listener/legacy_validator_spec.rb +1 -1
- data/spec/controllers/listener/login_credential_acceptor_spec.rb +1 -1
- data/spec/controllers/listener/login_credential_requestor_spec.rb +1 -1
- data/spec/controllers/listener/logout_spec.rb +1 -1
- data/spec/controllers/listener/other_sessions_destroyer_spec.rb +1 -1
- data/spec/controllers/listener/proxy_ticket_provider_spec.rb +1 -1
- data/spec/controllers/listener/second_factor_authentication_acceptor_spec.rb +1 -1
- data/spec/controllers/listener/session_destroyer_spec.rb +1 -1
- data/spec/controllers/listener/session_overview_spec.rb +1 -1
- data/spec/controllers/listener/ticket_validator_spec.rb +1 -1
- data/spec/controllers/listener/two_factor_authenticator_activator_spec.rb +1 -1
- data/spec/controllers/listener/two_factor_authenticator_destroyer_spec.rb +1 -1
- data/spec/controllers/listener/two_factor_authenticator_overview_spec.rb +1 -1
- data/spec/controllers/listener/two_factor_authenticator_registrator_spec.rb +1 -1
- data/spec/controllers/proxy_tickets_controller_spec.rb +4 -4
- data/spec/controllers/service_tickets_controller_spec.rb +4 -4
- data/spec/controllers/sessions_controller_spec.rb +15 -15
- data/spec/controllers/two_factor_authenticators_controller_spec.rb +6 -6
- data/spec/dummy/app/assets/stylesheets/casino_and_overrides.scss +13 -0
- data/spec/dummy/config/cas.yml +11 -11
- data/spec/dummy/config/routes.rb +1 -2
- data/spec/dummy/db/migrate/20130910094259_create_base_models.casino.rb +95 -0
- data/spec/dummy/db/schema.rb +107 -0
- data/spec/model/login_ticket_spec.rb +23 -0
- data/spec/model/proxy_ticket_spec.rb +63 -0
- data/spec/model/service_rule_spec.rb +65 -0
- data/spec/model/service_ticket/single_sign_out_notifier_spec.rb +61 -0
- data/spec/model/service_ticket_spec.rb +124 -0
- data/spec/model/ticket_granting_ticket_spec.rb +204 -0
- data/spec/model/two_factor_authenticator_spec.rb +31 -0
- data/spec/processor/api/login_credential_acceptor_spec.rb +52 -0
- data/spec/processor/api/logout_spec.rb +34 -0
- data/spec/processor/api/service_ticket_provider_spec.rb +61 -0
- data/spec/processor/legacy_validator_spec.rb +78 -0
- data/spec/processor/login_credential_acceptor_spec.rb +164 -0
- data/spec/processor/login_credential_requestor_spec.rb +135 -0
- data/spec/processor/logout_other_sessions_spec.rb +53 -0
- data/spec/processor/logout_spec.rb +72 -0
- data/spec/processor/processor_concern/service_tickets_spec.rb +49 -0
- data/spec/processor/proxy_ticket_provider_spec.rb +66 -0
- data/spec/processor/proxy_ticket_validator_spec.rb +65 -0
- data/spec/processor/second_factor_authenticaton_acceptor_spec.rb +94 -0
- data/spec/processor/session_destroyer_spec.rb +75 -0
- data/spec/processor/session_overview_spec.rb +49 -0
- data/spec/processor/ticket_validator_spec.rb +199 -0
- data/spec/processor/two_factor_authenticator_activator_spec.rb +122 -0
- data/spec/processor/two_factor_authenticator_destroyer_spec.rb +71 -0
- data/spec/processor/two_factor_authenticator_overview_spec.rb +56 -0
- data/spec/processor/two_factor_authenticator_registrator_spec.rb +48 -0
- data/spec/spec_helper.rb +8 -19
- data/spec/support/casino.rb +12 -0
- data/spec/support/factories/login_ticket_factory.rb +16 -0
- data/spec/support/factories/proxy_granting_ticket_factory.rb +16 -0
- data/spec/support/factories/proxy_ticket_factory.rb +17 -0
- data/spec/support/factories/service_rule_factory.rb +16 -0
- data/spec/support/factories/service_ticket_factory.rb +17 -0
- data/spec/support/factories/ticket_granting_ticket_factory.rb +15 -0
- data/spec/support/factories/two_factor_authenticator_factory.rb +16 -0
- data/spec/support/factories/user_factory.rb +11 -0
- data/spec/support/rspec.rb +8 -0
- data/spec/support/sqlite3.rb +4 -0
- metadata +284 -48
- metadata.gz.sig +2 -0
- data/.powrc +0 -4
- data/Gemfile.lock +0 -149
- data/app/assets/javascripts/casino/application.js.coffee +0 -5
- data/app/assets/javascripts/casino/sessions.js.coffee +0 -15
- data/config/initializers/frontend_config.rb +0 -9
- data/config/initializers/inflections.rb +0 -19
- data/config/initializers/yaml.rb +0 -1
- data/lib/casino/listener.rb +0 -31
- data/lib/generators/casino/install_generator.rb +0 -35
- data/spec/dummy/config/initializers/casino_core.rb +0 -1
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe CASino::TwoFactorAuthenticatorsController do
|
4
4
|
describe 'GET "new"' do
|
5
5
|
it 'calls the process method of the TwoFactorAuthenticatorRegistrator' do
|
6
|
-
|
7
|
-
get :new
|
6
|
+
CASino::TwoFactorAuthenticatorRegistratorProcessor.any_instance.should_receive(:process)
|
7
|
+
get :new, use_route: :casino
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe 'POST "create"' do
|
12
12
|
it 'calls the process method of the TwoFactorAuthenticatorActivator' do
|
13
|
-
|
13
|
+
CASino::TwoFactorAuthenticatorActivatorProcessor.any_instance.should_receive(:process) do
|
14
14
|
@controller.render nothing: true
|
15
15
|
end
|
16
|
-
post :create
|
16
|
+
post :create, use_route: :casino
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,13 +22,13 @@ describe CASino::TwoFactorAuthenticatorsController do
|
|
22
22
|
let(:tgt) { 'TGT-foobar' }
|
23
23
|
it 'calls the process method of the TwoFactorAuthenticatorDestroyer processor' do
|
24
24
|
request.cookies[:tgt] = tgt
|
25
|
-
|
25
|
+
CASino::TwoFactorAuthenticatorDestroyerProcessor.any_instance.should_receive(:process) do |params, cookies, user_agent|
|
26
26
|
params[:id].should == id
|
27
27
|
cookies[:tgt].should == tgt
|
28
28
|
user_agent.should == request.user_agent
|
29
29
|
@controller.render nothing: true
|
30
30
|
end
|
31
|
-
delete :destroy, id:
|
31
|
+
delete :destroy, id:id, use_route: :casino
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/spec/dummy/config/cas.yml
CHANGED
@@ -7,23 +7,23 @@ defaults: &defaults
|
|
7
7
|
proxy_ticket:
|
8
8
|
lifetime_unconsumed: 300
|
9
9
|
lifetime_consumed: 86400
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
frontend:
|
11
|
+
sso_name: "CASino"
|
12
|
+
footer_text: "Powered by <a href=\"http://rbcas.com/\">CASino</a>"
|
13
13
|
authenticators:
|
14
14
|
static:
|
15
|
-
class: "
|
15
|
+
class: "CASino::StaticAuthenticator"
|
16
16
|
options:
|
17
17
|
users:
|
18
18
|
testuser:
|
19
19
|
password: "foobar123"
|
20
|
+
name: "Test User"
|
21
|
+
|
22
|
+
development:
|
23
|
+
<<: *defaults
|
20
24
|
|
21
25
|
test:
|
22
26
|
<<: *defaults
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
options:
|
27
|
-
users:
|
28
|
-
testuser:
|
29
|
-
password: "foobar123"
|
27
|
+
|
28
|
+
production:
|
29
|
+
<<: *defaults
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
# This migration comes from casino (originally 20130809135401)
|
2
|
+
class CreateBaseModels < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
# Login Tickets
|
5
|
+
create_table :casino_login_tickets do |t|
|
6
|
+
t.string :ticket, :null => false
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :casino_login_tickets, :ticket, :unique => true
|
11
|
+
|
12
|
+
# Proxy Granting Tickets
|
13
|
+
create_table :casino_proxy_granting_tickets do |t|
|
14
|
+
t.string :ticket, :null => false
|
15
|
+
t.string :iou, :null => false
|
16
|
+
t.integer :granter_id, :null => false
|
17
|
+
t.string :pgt_url, :null => false
|
18
|
+
t.string :granter_type, :null => false
|
19
|
+
|
20
|
+
t.timestamps
|
21
|
+
end
|
22
|
+
add_index :casino_proxy_granting_tickets, :ticket, :unique => true
|
23
|
+
add_index :casino_proxy_granting_tickets, :iou, :unique => true
|
24
|
+
add_index :casino_proxy_granting_tickets, [:granter_type, :granter_id], :name => "index_casino_proxy_granting_tickets_on_granter", :unique => true
|
25
|
+
|
26
|
+
# Proxy Tickets
|
27
|
+
create_table :casino_proxy_tickets do |t|
|
28
|
+
t.string :ticket, :null => false
|
29
|
+
t.string :service, :null => false
|
30
|
+
t.boolean :consumed, :default => false, :null => false
|
31
|
+
t.integer :proxy_granting_ticket_id, :null => false
|
32
|
+
|
33
|
+
t.timestamps
|
34
|
+
end
|
35
|
+
add_index :casino_proxy_tickets, :ticket, :unique => true
|
36
|
+
add_index :casino_proxy_tickets, :proxy_granting_ticket_id
|
37
|
+
|
38
|
+
# Service Rules
|
39
|
+
create_table :casino_service_rules do |t|
|
40
|
+
t.boolean :enabled, :default => true, :null => false
|
41
|
+
t.integer :order, :default => 10, :null => false
|
42
|
+
t.string :name, :null => false
|
43
|
+
t.string :url, :null => false
|
44
|
+
t.boolean :regex, :default => false, :null => false
|
45
|
+
|
46
|
+
t.timestamps
|
47
|
+
end
|
48
|
+
add_index :casino_service_rules, :url, :unique => true
|
49
|
+
|
50
|
+
# Service Tickets
|
51
|
+
create_table :casino_service_tickets do |t|
|
52
|
+
t.string :ticket, :null => false
|
53
|
+
t.string :service, :null => false
|
54
|
+
t.integer :ticket_granting_ticket_id
|
55
|
+
t.boolean :consumed, :default => false, :null => false
|
56
|
+
t.boolean :issued_from_credentials, :default => false, :null => false
|
57
|
+
|
58
|
+
t.timestamps
|
59
|
+
end
|
60
|
+
add_index :casino_service_tickets, :ticket, :unique => true
|
61
|
+
add_index :casino_service_tickets, :ticket_granting_ticket_id
|
62
|
+
|
63
|
+
# Ticket Granting Tickets
|
64
|
+
create_table :casino_ticket_granting_tickets do |t|
|
65
|
+
t.string :ticket, :null => false
|
66
|
+
t.string :user_agent
|
67
|
+
t.integer :user_id, :null => false
|
68
|
+
t.boolean :awaiting_two_factor_authentication, :default => false, :null => false
|
69
|
+
t.boolean :long_term, :default => false, :null => false
|
70
|
+
|
71
|
+
t.timestamps
|
72
|
+
end
|
73
|
+
add_index :casino_ticket_granting_tickets, :ticket, :unique => true
|
74
|
+
|
75
|
+
# Two Factor Authenticators
|
76
|
+
create_table :casino_two_factor_authenticators do |t|
|
77
|
+
t.integer :user_id, :null => false
|
78
|
+
t.string :secret, :null => false
|
79
|
+
t.boolean :active, :default => false, :null => false
|
80
|
+
|
81
|
+
t.timestamps
|
82
|
+
end
|
83
|
+
add_index :casino_two_factor_authenticators, :user_id
|
84
|
+
|
85
|
+
# Users
|
86
|
+
create_table :casino_users do |t|
|
87
|
+
t.string :authenticator, :null => false
|
88
|
+
t.string :username, :null => false
|
89
|
+
t.text :extra_attributes
|
90
|
+
|
91
|
+
t.timestamps
|
92
|
+
end
|
93
|
+
add_index :casino_users, [:authenticator, :username], :unique => true
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20130910094259) do
|
15
|
+
|
16
|
+
create_table "casino_login_tickets", :force => true do |t|
|
17
|
+
t.string "ticket", :null => false
|
18
|
+
t.datetime "created_at", :null => false
|
19
|
+
t.datetime "updated_at", :null => false
|
20
|
+
end
|
21
|
+
|
22
|
+
add_index "casino_login_tickets", ["ticket"], :name => "index_casino_login_tickets_on_ticket", :unique => true
|
23
|
+
|
24
|
+
create_table "casino_proxy_granting_tickets", :force => true do |t|
|
25
|
+
t.string "ticket", :null => false
|
26
|
+
t.string "iou", :null => false
|
27
|
+
t.integer "granter_id", :null => false
|
28
|
+
t.string "pgt_url", :null => false
|
29
|
+
t.string "granter_type", :null => false
|
30
|
+
t.datetime "created_at", :null => false
|
31
|
+
t.datetime "updated_at", :null => false
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index "casino_proxy_granting_tickets", ["granter_type", "granter_id"], :name => "index_casino_proxy_granting_tickets_on_granter", :unique => true
|
35
|
+
add_index "casino_proxy_granting_tickets", ["iou"], :name => "index_casino_proxy_granting_tickets_on_iou", :unique => true
|
36
|
+
add_index "casino_proxy_granting_tickets", ["ticket"], :name => "index_casino_proxy_granting_tickets_on_ticket", :unique => true
|
37
|
+
|
38
|
+
create_table "casino_proxy_tickets", :force => true do |t|
|
39
|
+
t.string "ticket", :null => false
|
40
|
+
t.string "service", :null => false
|
41
|
+
t.boolean "consumed", :default => false, :null => false
|
42
|
+
t.integer "proxy_granting_ticket_id", :null => false
|
43
|
+
t.datetime "created_at", :null => false
|
44
|
+
t.datetime "updated_at", :null => false
|
45
|
+
end
|
46
|
+
|
47
|
+
add_index "casino_proxy_tickets", ["proxy_granting_ticket_id"], :name => "index_casino_proxy_tickets_on_proxy_granting_ticket_id"
|
48
|
+
add_index "casino_proxy_tickets", ["ticket"], :name => "index_casino_proxy_tickets_on_ticket", :unique => true
|
49
|
+
|
50
|
+
create_table "casino_service_rules", :force => true do |t|
|
51
|
+
t.boolean "enabled", :default => true, :null => false
|
52
|
+
t.integer "order", :default => 10, :null => false
|
53
|
+
t.string "name", :null => false
|
54
|
+
t.string "url", :null => false
|
55
|
+
t.boolean "regex", :default => false, :null => false
|
56
|
+
t.datetime "created_at", :null => false
|
57
|
+
t.datetime "updated_at", :null => false
|
58
|
+
end
|
59
|
+
|
60
|
+
add_index "casino_service_rules", ["url"], :name => "index_casino_service_rules_on_url", :unique => true
|
61
|
+
|
62
|
+
create_table "casino_service_tickets", :force => true do |t|
|
63
|
+
t.string "ticket", :null => false
|
64
|
+
t.string "service", :null => false
|
65
|
+
t.integer "ticket_granting_ticket_id"
|
66
|
+
t.boolean "consumed", :default => false, :null => false
|
67
|
+
t.boolean "issued_from_credentials", :default => false, :null => false
|
68
|
+
t.datetime "created_at", :null => false
|
69
|
+
t.datetime "updated_at", :null => false
|
70
|
+
end
|
71
|
+
|
72
|
+
add_index "casino_service_tickets", ["ticket"], :name => "index_casino_service_tickets_on_ticket", :unique => true
|
73
|
+
add_index "casino_service_tickets", ["ticket_granting_ticket_id"], :name => "index_casino_service_tickets_on_ticket_granting_ticket_id"
|
74
|
+
|
75
|
+
create_table "casino_ticket_granting_tickets", :force => true do |t|
|
76
|
+
t.string "ticket", :null => false
|
77
|
+
t.string "user_agent"
|
78
|
+
t.integer "user_id", :null => false
|
79
|
+
t.boolean "awaiting_two_factor_authentication", :default => false, :null => false
|
80
|
+
t.boolean "long_term", :default => false, :null => false
|
81
|
+
t.datetime "created_at", :null => false
|
82
|
+
t.datetime "updated_at", :null => false
|
83
|
+
end
|
84
|
+
|
85
|
+
add_index "casino_ticket_granting_tickets", ["ticket"], :name => "index_casino_ticket_granting_tickets_on_ticket", :unique => true
|
86
|
+
|
87
|
+
create_table "casino_two_factor_authenticators", :force => true do |t|
|
88
|
+
t.integer "user_id", :null => false
|
89
|
+
t.string "secret", :null => false
|
90
|
+
t.boolean "active", :default => false, :null => false
|
91
|
+
t.datetime "created_at", :null => false
|
92
|
+
t.datetime "updated_at", :null => false
|
93
|
+
end
|
94
|
+
|
95
|
+
add_index "casino_two_factor_authenticators", ["user_id"], :name => "index_casino_two_factor_authenticators_on_user_id"
|
96
|
+
|
97
|
+
create_table "casino_users", :force => true do |t|
|
98
|
+
t.string "authenticator", :null => false
|
99
|
+
t.string "username", :null => false
|
100
|
+
t.text "extra_attributes"
|
101
|
+
t.datetime "created_at", :null => false
|
102
|
+
t.datetime "updated_at", :null => false
|
103
|
+
end
|
104
|
+
|
105
|
+
add_index "casino_users", ["authenticator", "username"], :name => "index_casino_users_on_authenticator_and_username", :unique => true
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CASino::LoginTicket do
|
4
|
+
describe '.cleanup' do
|
5
|
+
it 'deletes expired login tickets' do
|
6
|
+
ticket = described_class.new ticket: 'LT-12345'
|
7
|
+
ticket.save!
|
8
|
+
ticket.created_at = 10.hours.ago
|
9
|
+
ticket.save!
|
10
|
+
lambda do
|
11
|
+
described_class.cleanup
|
12
|
+
end.should change(described_class, :count).by(-1)
|
13
|
+
described_class.find_by_ticket('LT-12345').should be_false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#to_s' do
|
18
|
+
it 'returns the ticket identifier' do
|
19
|
+
ticket = described_class.new ticket: 'LT-12345'
|
20
|
+
"#{ticket}".should == ticket.ticket
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CASino::ProxyTicket do
|
4
|
+
let(:unconsumed_ticket) {
|
5
|
+
ticket = described_class.new ticket: 'PT-12345', service: 'any_string_is_valid'
|
6
|
+
ticket.proxy_granting_ticket_id = 1
|
7
|
+
ticket
|
8
|
+
}
|
9
|
+
let(:consumed_ticket) {
|
10
|
+
ticket = described_class.new ticket: 'PT-54321', service: 'any_string_is_valid'
|
11
|
+
ticket.proxy_granting_ticket_id = 1
|
12
|
+
ticket.consumed = true
|
13
|
+
ticket.save!
|
14
|
+
ticket
|
15
|
+
}
|
16
|
+
|
17
|
+
describe '#expired?' do
|
18
|
+
[:unconsumed, :consumed].each do |state|
|
19
|
+
context "with an #{state} ticket" do
|
20
|
+
let(:ticket) { send("#{state}_ticket") }
|
21
|
+
|
22
|
+
context 'with an expired ticket' do
|
23
|
+
before(:each) do
|
24
|
+
ticket.created_at = (CASino.config.service_ticket[:"lifetime_#{state}"].seconds + 1).ago
|
25
|
+
ticket.save!
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns true' do
|
29
|
+
ticket.expired?.should == true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with an unexpired ticket' do
|
34
|
+
it 'returns false' do
|
35
|
+
ticket.expired?.should == false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.cleanup_unconsumed' do
|
43
|
+
it 'deletes expired unconsumed service tickets' do
|
44
|
+
unconsumed_ticket.created_at = 10.hours.ago
|
45
|
+
unconsumed_ticket.save!
|
46
|
+
lambda do
|
47
|
+
described_class.cleanup_unconsumed
|
48
|
+
end.should change(described_class, :count).by(-1)
|
49
|
+
described_class.find_by_ticket('PT-12345').should be_false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.cleanup_consumed' do
|
54
|
+
it 'deletes expired consumed service tickets' do
|
55
|
+
consumed_ticket.created_at = 10.days.ago
|
56
|
+
consumed_ticket.save!
|
57
|
+
lambda do
|
58
|
+
described_class.cleanup_consumed
|
59
|
+
end.should change(described_class, :count).by(-1)
|
60
|
+
described_class.find_by_ticket('PT-12345').should be_false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CASino::ServiceRule do
|
4
|
+
describe '.allowed?' do
|
5
|
+
context 'with an empty table' do
|
6
|
+
['https://www.example.org/', 'http://www.google.com/'].each do |service_url|
|
7
|
+
it "allows access to #{service_url}" do
|
8
|
+
described_class.allowed?(service_url).should == true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with a regex rule' do
|
14
|
+
before(:each) do
|
15
|
+
FactoryGirl.create :service_rule, :regex, url: '^https://.*'
|
16
|
+
end
|
17
|
+
|
18
|
+
['https://www.example.org/', 'https://www.google.com/'].each do |service_url|
|
19
|
+
it "allows access to #{service_url}" do
|
20
|
+
described_class.allowed?(service_url).should == true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
['http://www.example.org/', 'http://www.google.com/'].each do |service_url|
|
25
|
+
it "does not allow access to #{service_url}" do
|
26
|
+
described_class.allowed?(service_url).should == false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with many regex rules' do
|
32
|
+
before(:each) do
|
33
|
+
100.times do |counter|
|
34
|
+
FactoryGirl.create :service_rule, :regex, url: "^https://www#{counter}.example.com"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:service_url) { 'https://www111.example.com/bla' }
|
39
|
+
|
40
|
+
it 'does not take too long to check a denied service' do
|
41
|
+
start = Time.now
|
42
|
+
described_class.allowed?(service_url).should == false
|
43
|
+
(Time.now - start).should < 0.1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with a non-regex rule' do
|
48
|
+
before(:each) do
|
49
|
+
FactoryGirl.create :service_rule, url: 'https://www.google.com/foo'
|
50
|
+
end
|
51
|
+
|
52
|
+
['https://www.google.com/foo'].each do |service_url|
|
53
|
+
it "allows access to #{service_url}" do
|
54
|
+
described_class.allowed?(service_url).should == true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
['https://www.example.org/', 'http://www.example.org/', 'https://www.google.com/test'].each do |service_url|
|
59
|
+
it "does not allow access to #{service_url}" do
|
60
|
+
described_class.allowed?(service_url).should == false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|