casino 3.0.4 → 4.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +12 -3
- data/app/api/casino/api.rb +7 -0
- data/app/api/casino/api/entity/auth_token_ticket.rb +5 -0
- data/app/api/casino/api/resource/auth_token_tickets.rb +12 -0
- data/app/assets/javascripts/casino/{application.js → application.js.erb} +1 -1
- data/app/authenticators/casino/static_authenticator.rb +8 -2
- data/app/builders/casino/proxy_response_builder.rb +24 -0
- data/app/builders/casino/ticket_validation_response_builder.rb +9 -5
- data/app/controllers/casino/application_controller.rb +0 -22
- data/app/controllers/casino/auth_tokens_controller.rb +34 -0
- data/app/controllers/casino/controller_concern/ticket_validator.rb +30 -0
- data/app/controllers/casino/proxy_tickets_controller.rb +42 -2
- data/app/controllers/casino/service_tickets_controller.rb +15 -2
- data/app/controllers/casino/sessions_controller.rb +59 -8
- data/app/controllers/casino/two_factor_authenticators_controller.rb +28 -3
- data/app/helpers/casino/sessions_helper.rb +75 -0
- data/app/helpers/casino/two_factor_authenticators_helper.rb +12 -0
- data/app/models/casino/auth_token_ticket.rb +15 -0
- data/app/models/casino/login_ticket.rb +7 -4
- data/app/models/casino/model_concern/consumable_ticket.rb +20 -0
- data/app/models/casino/model_concern/ticket.rb +28 -0
- data/app/models/casino/proxy_granting_ticket.rb +12 -0
- data/app/models/casino/proxy_ticket.rb +4 -0
- data/app/models/casino/service_ticket.rb +5 -4
- data/app/models/casino/ticket_granting_ticket.rb +5 -1
- data/app/models/casino/two_factor_authenticator.rb +2 -0
- data/app/processors/casino/authentication_processor.rb +73 -0
- data/app/processors/casino/browser_processor.rb +12 -0
- data/app/processors/casino/proxy_granting_ticket_processor.rb +37 -0
- data/app/processors/casino/service_ticket_processor.rb +81 -0
- data/app/processors/casino/ticket_granting_ticket_processor.rb +56 -0
- data/app/processors/casino/two_factor_authenticator_processor.rb +18 -0
- data/app/services/casino/auth_token_validation_service.rb +66 -0
- data/app/views/casino/sessions/index.html.erb +2 -2
- data/app/views/casino/sessions/new.html.erb +1 -1
- data/app/views/casino/sessions/validate_otp.html.erb +1 -1
- data/app/views/casino/two_factor_authenticators/new.html.erb +6 -3
- data/app/views/layouts/application.html.erb +0 -1
- data/casino.gemspec +4 -2
- data/config/locales/en.yml +35 -0
- data/config/locales/zh-CN.yml +88 -0
- data/config/locales/zh-TW.yml +88 -0
- data/config/routes.rb +3 -10
- data/db/migrate/20140831205255_create_auth_token_tickets.rb +10 -0
- data/lib/casino.rb +4 -1
- data/lib/casino/tasks/cleanup.rake +13 -1
- data/lib/casino/version.rb +1 -1
- data/spec/controllers/auth_tokens_controller_spec.rb +75 -0
- data/spec/controllers/proxy_tickets_controller_spec.rb +120 -14
- data/spec/controllers/service_and_proxy_tickets_controller_spec.rb +224 -0
- data/spec/controllers/service_tickets_controller_spec.rb +62 -16
- data/spec/controllers/sessions_controller_spec.rb +622 -36
- data/spec/controllers/two_factor_authenticators_controller_spec.rb +217 -18
- data/spec/dummy/config/cas.yml +3 -0
- data/spec/dummy/config/environments/development.rb +0 -4
- data/spec/dummy/db/migrate/{20130910094259_create_base_models.casino.rb → 20140831214845_create_core_schema.casino.rb} +55 -32
- data/spec/dummy/db/migrate/20140831214846_rename_base_models.casino.rb +102 -0
- data/spec/dummy/db/migrate/20140831214847_cleanup_indexes.casino.rb +28 -0
- data/spec/dummy/db/migrate/20140831214848_fix_long_index_names.casino.rb +13 -0
- data/spec/dummy/db/migrate/20140831214849_change_service_to_text.casino.rb +7 -0
- data/spec/dummy/db/migrate/20140831214850_change_user_agent_to_text.casino.rb +6 -0
- data/spec/dummy/db/migrate/20140831214851_fix_length_of_text_fields.casino.rb +8 -0
- data/spec/dummy/db/migrate/20140831214852_create_auth_token_tickets.casino.rb +11 -0
- data/spec/dummy/db/schema.rb +79 -70
- data/spec/features/login_spec.rb +0 -9
- data/spec/model/auth_token_ticket_spec.rb +23 -0
- data/spec/services/auth_token_validation_service_spec.rb +83 -0
- data/spec/support/sign_in.rb +4 -0
- metadata +139 -210
- data/app/controllers/casino/api/v1/tickets_controller.rb +0 -55
- data/app/helpers/service_tickets_helper.rb +0 -2
- data/app/listeners/casino/legacy_validator_listener.rb +0 -11
- data/app/listeners/casino/listener.rb +0 -16
- data/app/listeners/casino/login_credential_acceptor_listener.rb +0 -38
- data/app/listeners/casino/login_credential_requestor_listener.rb +0 -21
- data/app/listeners/casino/logout_listener.rb +0 -12
- data/app/listeners/casino/other_sessions_destroyer_listener.rb +0 -7
- data/app/listeners/casino/proxy_ticket_provider_listener.rb +0 -11
- data/app/listeners/casino/second_factor_authentication_acceptor_listener.rb +0 -26
- data/app/listeners/casino/session_destroyer_listener.rb +0 -11
- data/app/listeners/casino/session_overview_listener.rb +0 -11
- data/app/listeners/casino/ticket_validator_listener.rb +0 -11
- data/app/listeners/casino/two_factor_authenticator_activator_listener.rb +0 -23
- data/app/listeners/casino/two_factor_authenticator_destroyer_listener.rb +0 -16
- data/app/listeners/casino/two_factor_authenticator_overview_listener.rb +0 -11
- data/app/listeners/casino/two_factor_authenticator_registrator_listener.rb +0 -11
- data/app/processors/casino/api/login_credential_acceptor_processor.rb +0 -46
- data/app/processors/casino/api/logout_processor.rb +0 -17
- data/app/processors/casino/api/service_ticket_provider_processor.rb +0 -69
- data/app/processors/casino/legacy_validator_processor.rb +0 -19
- data/app/processors/casino/login_credential_acceptor_processor.rb +0 -63
- data/app/processors/casino/login_credential_requestor_processor.rb +0 -70
- data/app/processors/casino/logout_processor.rb +0 -23
- data/app/processors/casino/other_sessions_destroyer_processor.rb +0 -26
- data/app/processors/casino/processor.rb +0 -5
- data/app/processors/casino/processor_concern/authentication.rb +0 -87
- data/app/processors/casino/processor_concern/browser.rb +0 -14
- data/app/processors/casino/processor_concern/login_tickets.rb +0 -28
- data/app/processors/casino/processor_concern/proxy_granting_tickets.rb +0 -43
- data/app/processors/casino/processor_concern/proxy_tickets.rb +0 -56
- data/app/processors/casino/processor_concern/service_tickets.rb +0 -50
- data/app/processors/casino/processor_concern/ticket_granting_tickets.rb +0 -65
- data/app/processors/casino/processor_concern/tickets.rb +0 -17
- data/app/processors/casino/processor_concern/two_factor_authenticators.rb +0 -23
- data/app/processors/casino/proxy_ticket_provider_processor.rb +0 -41
- data/app/processors/casino/proxy_ticket_validator_processor.rb +0 -22
- data/app/processors/casino/second_factor_authentication_acceptor_processor.rb +0 -45
- data/app/processors/casino/service_ticket_validator_processor.rb +0 -46
- data/app/processors/casino/session_destroyer_processor.rb +0 -25
- data/app/processors/casino/session_overview_processor.rb +0 -21
- data/app/processors/casino/two_factor_authenticator_activator_processor.rb +0 -41
- data/app/processors/casino/two_factor_authenticator_destroyer_processor.rb +0 -33
- data/app/processors/casino/two_factor_authenticator_overview_processor.rb +0 -20
- data/app/processors/casino/two_factor_authenticator_registrator_processor.rb +0 -24
- data/spec/controllers/api/v1/tickets_controller_spec.rb +0 -114
- data/spec/controllers/listener/legacy_validator_spec.rb +0 -22
- data/spec/controllers/listener/login_credential_acceptor_spec.rb +0 -108
- data/spec/controllers/listener/login_credential_requestor_spec.rb +0 -57
- data/spec/controllers/listener/logout_spec.rb +0 -38
- data/spec/controllers/listener/other_sessions_destroyer_spec.rb +0 -19
- data/spec/controllers/listener/proxy_ticket_provider_spec.rb +0 -22
- data/spec/controllers/listener/second_factor_authentication_acceptor_spec.rb +0 -74
- data/spec/controllers/listener/session_destroyer_spec.rb +0 -25
- data/spec/controllers/listener/session_overview_spec.rb +0 -26
- data/spec/controllers/listener/ticket_validator_spec.rb +0 -22
- data/spec/controllers/listener/two_factor_authenticator_activator_spec.rb +0 -64
- data/spec/controllers/listener/two_factor_authenticator_destroyer_spec.rb +0 -40
- data/spec/controllers/listener/two_factor_authenticator_overview_spec.rb +0 -16
- data/spec/controllers/listener/two_factor_authenticator_registrator_spec.rb +0 -27
- data/spec/processor/api/login_credential_acceptor_spec.rb +0 -52
- data/spec/processor/api/logout_spec.rb +0 -34
- data/spec/processor/api/service_ticket_provider_spec.rb +0 -61
- data/spec/processor/legacy_validator_spec.rb +0 -78
- data/spec/processor/login_credential_acceptor_spec.rb +0 -164
- data/spec/processor/login_credential_requestor_spec.rb +0 -145
- data/spec/processor/logout_other_sessions_spec.rb +0 -53
- data/spec/processor/logout_spec.rb +0 -72
- data/spec/processor/processor_concern/service_tickets_spec.rb +0 -49
- data/spec/processor/proxy_ticket_provider_spec.rb +0 -66
- data/spec/processor/proxy_ticket_validator_spec.rb +0 -65
- data/spec/processor/second_factor_authenticaton_acceptor_spec.rb +0 -94
- data/spec/processor/session_destroyer_spec.rb +0 -75
- data/spec/processor/session_overview_spec.rb +0 -49
- data/spec/processor/ticket_validator_spec.rb +0 -214
- data/spec/processor/two_factor_authenticator_activator_spec.rb +0 -122
- data/spec/processor/two_factor_authenticator_destroyer_spec.rb +0 -71
- data/spec/processor/two_factor_authenticator_overview_spec.rb +0 -56
- data/spec/processor/two_factor_authenticator_registrator_spec.rb +0 -48
@@ -1,34 +1,233 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CASino::TwoFactorAuthenticatorsController do
|
4
|
+
include CASino::Engine.routes.url_helpers
|
5
|
+
let(:params) { { } }
|
6
|
+
let(:request_options) { params.merge(use_route: :casino) }
|
7
|
+
|
4
8
|
describe 'GET "new"' do
|
5
|
-
|
6
|
-
|
7
|
-
|
9
|
+
context 'with an existing ticket-granting ticket' do
|
10
|
+
let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }
|
11
|
+
let(:user) { ticket_granting_ticket.user }
|
12
|
+
let(:user_agent) { ticket_granting_ticket.user_agent }
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
sign_in(ticket_granting_ticket)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'creates exactly one authenticator' do
|
19
|
+
lambda do
|
20
|
+
get :new, request_options
|
21
|
+
end.should change(CASino::TwoFactorAuthenticator, :count).by(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'assigns the two_factor_authenticator' do
|
25
|
+
get :new, request_options
|
26
|
+
assigns(:two_factor_authenticator).should be_kind_of(CASino::TwoFactorAuthenticator)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'creates an inactive two-factor authenticator' do
|
30
|
+
get :new, request_options
|
31
|
+
CASino::TwoFactorAuthenticator.last.should_not be_active
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'renders the new template' do
|
35
|
+
get :new, request_options
|
36
|
+
response.should render_template(:new)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'without a ticket-granting ticket' do
|
41
|
+
it 'redirects to the login page' do
|
42
|
+
get :new, request_options
|
43
|
+
response.should redirect_to(login_path)
|
44
|
+
end
|
8
45
|
end
|
9
46
|
end
|
10
47
|
|
11
48
|
describe 'POST "create"' do
|
12
|
-
|
13
|
-
|
14
|
-
|
49
|
+
context 'with an existing ticket-granting ticket' do
|
50
|
+
let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }
|
51
|
+
let(:user) { ticket_granting_ticket.user }
|
52
|
+
let(:id) { two_factor_authenticator.id }
|
53
|
+
let(:otp) { '123456' }
|
54
|
+
let(:params) { { otp: otp, id: id } }
|
55
|
+
|
56
|
+
before(:each) do
|
57
|
+
sign_in(ticket_granting_ticket)
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with an invalid authenticator' do
|
61
|
+
context 'with an expired authenticator' do
|
62
|
+
let(:two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator, :inactive, user: user }
|
63
|
+
|
64
|
+
before(:each) do
|
65
|
+
two_factor_authenticator.created_at = 10.hours.ago
|
66
|
+
two_factor_authenticator.save!
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'redirects to the two-factor authenticator new page' do
|
70
|
+
post :create, request_options
|
71
|
+
response.should redirect_to(new_two_factor_authenticator_path)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'adds a error message' do
|
75
|
+
post :create, request_options
|
76
|
+
flash[:error].should == I18n.t('two_factor_authenticators.invalid_two_factor_authenticator')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'with a authenticator of another user' do
|
81
|
+
let(:two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator, :inactive }
|
82
|
+
|
83
|
+
before(:each) do
|
84
|
+
two_factor_authenticator.created_at = 10.hours.ago
|
85
|
+
two_factor_authenticator.save!
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'redirects to the two-factor authenticator new page' do
|
89
|
+
post :create, request_options
|
90
|
+
response.should redirect_to(new_two_factor_authenticator_path)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'with a valid authenticator' do
|
96
|
+
let(:two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator, :inactive, user: user }
|
97
|
+
|
98
|
+
context 'with a valid OTP' do
|
99
|
+
before(:each) do
|
100
|
+
ROTP::TOTP.any_instance.should_receive(:verify_with_drift).with(otp, 30).and_return(true)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'redirects to the session overview' do
|
104
|
+
post :create, request_options
|
105
|
+
response.should redirect_to(sessions_path)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'adds a notice' do
|
109
|
+
post :create, request_options
|
110
|
+
flash[:notice].should == I18n.t('two_factor_authenticators.successfully_activated')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'does activate the authenticator' do
|
114
|
+
post :create, request_options
|
115
|
+
two_factor_authenticator.reload.should be_active
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when another two-factor authenticator was active' do
|
119
|
+
let!(:other_two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator, user: user }
|
120
|
+
|
121
|
+
it 'does activate the authenticator' do
|
122
|
+
post :create, request_options
|
123
|
+
two_factor_authenticator.reload.should be_active
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'does delete the other authenticator' do
|
127
|
+
post :create, request_options
|
128
|
+
lambda do
|
129
|
+
other_two_factor_authenticator.reload
|
130
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'with an invalid OTP' do
|
137
|
+
before(:each) do
|
138
|
+
ROTP::TOTP.any_instance.should_receive(:verify_with_drift).with(otp, 30).and_return(false)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'rerenders the new page' do
|
142
|
+
post :create, request_options
|
143
|
+
response.should render_template(:new)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'adds a error message' do
|
147
|
+
post :create, request_options
|
148
|
+
flash[:error].should == I18n.t('two_factor_authenticators.invalid_one_time_password')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'assigns the two-factor authenticator' do
|
152
|
+
post :create, request_options
|
153
|
+
assigns(:two_factor_authenticator).should be_kind_of(CASino::TwoFactorAuthenticator)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'does not activate the authenticator' do
|
157
|
+
post :create, request_options
|
158
|
+
two_factor_authenticator.reload.should_not be_active
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'without a ticket-granting ticket' do
|
165
|
+
it 'redirects to the login page' do
|
166
|
+
post :create, request_options
|
167
|
+
response.should redirect_to(login_path)
|
15
168
|
end
|
16
|
-
post :create, use_route: :casino
|
17
169
|
end
|
18
170
|
end
|
19
171
|
|
20
172
|
describe 'DELETE "destroy"' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
173
|
+
context 'with an existing ticket-granting ticket' do
|
174
|
+
let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }
|
175
|
+
let(:user) { ticket_granting_ticket.user }
|
176
|
+
let(:params) { { id: two_factor_authenticator.id } }
|
177
|
+
|
178
|
+
before(:each) do
|
179
|
+
sign_in(ticket_granting_ticket)
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'with a valid two-factor authenticator' do
|
183
|
+
let!(:two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator, user: user }
|
184
|
+
let!(:other_two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator }
|
185
|
+
|
186
|
+
it 'redirects to the session overview' do
|
187
|
+
delete :destroy, request_options
|
188
|
+
response.should redirect_to(sessions_path)
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'adds a notice' do
|
192
|
+
delete :destroy, request_options
|
193
|
+
flash[:notice].should == I18n.t('two_factor_authenticators.successfully_deleted')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'deletes the two-factor authenticator' do
|
197
|
+
delete :destroy, request_options
|
198
|
+
lambda do
|
199
|
+
two_factor_authenticator.reload
|
200
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'does not delete other two-factor authenticators' do
|
204
|
+
lambda do
|
205
|
+
delete :destroy, request_options
|
206
|
+
end.should change(CASino::TwoFactorAuthenticator, :count).by(-1)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'with a two-factor authenticator of another user' do
|
211
|
+
let!(:two_factor_authenticator) { FactoryGirl.create :two_factor_authenticator }
|
212
|
+
|
213
|
+
it 'redirects to the session overview' do
|
214
|
+
delete :destroy, request_options
|
215
|
+
response.should redirect_to(sessions_path)
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'does not delete two-factor authenticators' do
|
219
|
+
lambda do
|
220
|
+
delete :destroy, request_options
|
221
|
+
end.should_not change(CASino::TwoFactorAuthenticator, :count)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'without a ticket-granting ticket' do
|
227
|
+
it 'redirects to the login page' do
|
228
|
+
delete :destroy, request_options
|
229
|
+
response.should redirect_to(login_path)
|
230
|
+
end
|
32
231
|
end
|
33
232
|
end
|
34
233
|
end
|
data/spec/dummy/config/cas.yml
CHANGED
@@ -22,10 +22,6 @@ Dummy::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
-
# Log the query plan for queries taking more than this (works
|
26
|
-
# with SQLite, MySQL, and PostgreSQL)
|
27
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
28
|
-
|
29
25
|
# Do not compress assets
|
30
26
|
config.assets.compress = false
|
31
27
|
|
@@ -1,16 +1,33 @@
|
|
1
|
-
# This migration comes from casino (originally
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# This migration comes from casino (originally 20130809135400)
|
2
|
+
# In order to support pre-2.0 installations of CASino that included CASinoCore,
|
3
|
+
# we must rebuild the un-namespaced CASinoCore schema so that we can upgrade
|
4
|
+
class CreateCoreSchema < ActiveRecord::Migration
|
5
|
+
CoreTables = %w{login_tickets proxy_granting_tickets proxy_tickets service_rules service_tickets ticket_granting_tickets two_factor_authenticators users}
|
6
|
+
|
7
|
+
def up
|
8
|
+
CoreTables.each do |table_name|
|
9
|
+
if !ActiveRecord::Base.connection.table_exists? table_name
|
10
|
+
send "create_#{table_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
# No-op
|
17
|
+
# Handled by 20130809135401_rename_base_models.rb
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_login_tickets
|
21
|
+
create_table :login_tickets do |t|
|
6
22
|
t.string :ticket, :null => false
|
7
23
|
|
8
24
|
t.timestamps
|
9
25
|
end
|
10
|
-
add_index :
|
26
|
+
add_index :login_tickets, :ticket, :unique => true
|
27
|
+
end
|
11
28
|
|
12
|
-
|
13
|
-
create_table :
|
29
|
+
def create_proxy_granting_tickets
|
30
|
+
create_table :proxy_granting_tickets do |t|
|
14
31
|
t.string :ticket, :null => false
|
15
32
|
t.string :iou, :null => false
|
16
33
|
t.integer :granter_id, :null => false
|
@@ -19,12 +36,13 @@ class CreateBaseModels < ActiveRecord::Migration
|
|
19
36
|
|
20
37
|
t.timestamps
|
21
38
|
end
|
22
|
-
add_index :
|
23
|
-
add_index :
|
24
|
-
add_index :
|
39
|
+
add_index :proxy_granting_tickets, :ticket, :unique => true
|
40
|
+
add_index :proxy_granting_tickets, :iou, :unique => true
|
41
|
+
add_index :proxy_granting_tickets, [:granter_type, :granter_id], :name => "index_proxy_granting_tickets_on_granter", :unique => true
|
42
|
+
end
|
25
43
|
|
26
|
-
|
27
|
-
create_table :
|
44
|
+
def create_proxy_tickets
|
45
|
+
create_table :proxy_tickets do |t|
|
28
46
|
t.string :ticket, :null => false
|
29
47
|
t.string :service, :null => false
|
30
48
|
t.boolean :consumed, :default => false, :null => false
|
@@ -32,11 +50,12 @@ class CreateBaseModels < ActiveRecord::Migration
|
|
32
50
|
|
33
51
|
t.timestamps
|
34
52
|
end
|
35
|
-
add_index :
|
36
|
-
add_index :
|
53
|
+
add_index :proxy_tickets, :ticket, :unique => true
|
54
|
+
add_index :proxy_tickets, :proxy_granting_ticket_id
|
55
|
+
end
|
37
56
|
|
38
|
-
|
39
|
-
create_table :
|
57
|
+
def create_service_rules
|
58
|
+
create_table :service_rules do |t|
|
40
59
|
t.boolean :enabled, :default => true, :null => false
|
41
60
|
t.integer :order, :default => 10, :null => false
|
42
61
|
t.string :name, :null => false
|
@@ -45,10 +64,11 @@ class CreateBaseModels < ActiveRecord::Migration
|
|
45
64
|
|
46
65
|
t.timestamps
|
47
66
|
end
|
48
|
-
add_index :
|
67
|
+
add_index :service_rules, :url, :unique => true
|
68
|
+
end
|
49
69
|
|
50
|
-
|
51
|
-
create_table :
|
70
|
+
def create_service_tickets
|
71
|
+
create_table :service_tickets do |t|
|
52
72
|
t.string :ticket, :null => false
|
53
73
|
t.string :service, :null => false
|
54
74
|
t.integer :ticket_granting_ticket_id
|
@@ -57,11 +77,12 @@ class CreateBaseModels < ActiveRecord::Migration
|
|
57
77
|
|
58
78
|
t.timestamps
|
59
79
|
end
|
60
|
-
add_index :
|
61
|
-
add_index :
|
80
|
+
add_index :service_tickets, :ticket, :unique => true
|
81
|
+
add_index :service_tickets, :ticket_granting_ticket_id
|
82
|
+
end
|
62
83
|
|
63
|
-
|
64
|
-
create_table :
|
84
|
+
def create_ticket_granting_tickets
|
85
|
+
create_table :ticket_granting_tickets do |t|
|
65
86
|
t.string :ticket, :null => false
|
66
87
|
t.string :user_agent
|
67
88
|
t.integer :user_id, :null => false
|
@@ -70,26 +91,28 @@ class CreateBaseModels < ActiveRecord::Migration
|
|
70
91
|
|
71
92
|
t.timestamps
|
72
93
|
end
|
73
|
-
add_index :
|
94
|
+
add_index :ticket_granting_tickets, :ticket, :unique => true
|
95
|
+
end
|
74
96
|
|
75
|
-
|
76
|
-
create_table :
|
97
|
+
def create_two_factor_authenticators
|
98
|
+
create_table :two_factor_authenticators do |t|
|
77
99
|
t.integer :user_id, :null => false
|
78
100
|
t.string :secret, :null => false
|
79
101
|
t.boolean :active, :default => false, :null => false
|
80
102
|
|
81
103
|
t.timestamps
|
82
104
|
end
|
83
|
-
add_index :
|
105
|
+
add_index :two_factor_authenticators, :user_id
|
106
|
+
end
|
84
107
|
|
85
|
-
|
86
|
-
create_table :
|
108
|
+
def create_users
|
109
|
+
create_table :users do |t|
|
87
110
|
t.string :authenticator, :null => false
|
88
111
|
t.string :username, :null => false
|
89
112
|
t.text :extra_attributes
|
90
113
|
|
91
114
|
t.timestamps
|
92
115
|
end
|
93
|
-
add_index :
|
116
|
+
add_index :users, [:authenticator, :username], :unique => true
|
94
117
|
end
|
95
|
-
end
|
118
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# This migration comes from casino (originally 20130809135401)
|
2
|
+
class RenameBaseModels < ActiveRecord::Migration
|
3
|
+
def up
|
4
|
+
# Login Tickets
|
5
|
+
rename_table :login_tickets, :casino_login_tickets
|
6
|
+
unless index_exists?(:casino_login_tickets, :ticket)
|
7
|
+
add_index :casino_login_tickets, :ticket, :unique => true
|
8
|
+
end
|
9
|
+
|
10
|
+
# Proxy Granting Tickets
|
11
|
+
rename_table :proxy_granting_tickets, :casino_proxy_granting_tickets
|
12
|
+
unless index_exists?(:casino_proxy_granting_tickets, :ticket)
|
13
|
+
add_index :casino_proxy_granting_tickets, :ticket, :unique => true
|
14
|
+
end
|
15
|
+
unless index_exists?(:casino_proxy_granting_tickets, :iou)
|
16
|
+
add_index :casino_proxy_granting_tickets, :iou, :unique => true
|
17
|
+
end
|
18
|
+
unless index_exists?(:casino_proxy_granting_tickets, :name => "index_casino_proxy_granting_tickets_on_granter")
|
19
|
+
# Uses a custom index name because the generated one exceeds the size limit
|
20
|
+
add_index :casino_proxy_granting_tickets, [:granter_type, :granter_id], :name => "index_casino_proxy_granting_tickets_on_granter", :unique => true
|
21
|
+
end
|
22
|
+
|
23
|
+
# Proxy Tickets
|
24
|
+
rename_table :proxy_tickets, :casino_proxy_tickets
|
25
|
+
unless index_exists?(:casino_proxy_tickets, :ticket)
|
26
|
+
add_index :casino_proxy_tickets, :ticket, :unique => true
|
27
|
+
end
|
28
|
+
unless index_exists?(:casino_proxy_tickets, :proxy_granting_ticket_id)
|
29
|
+
add_index :casino_proxy_tickets, :proxy_granting_ticket_id
|
30
|
+
end
|
31
|
+
|
32
|
+
# Service Rules
|
33
|
+
rename_table :service_rules, :casino_service_rules
|
34
|
+
unless index_exists?(:casino_service_rules, :url)
|
35
|
+
add_index :casino_service_rules, :url, :unique => true
|
36
|
+
end
|
37
|
+
|
38
|
+
# Service Tickets
|
39
|
+
rename_table :service_tickets, :casino_service_tickets
|
40
|
+
unless index_exists?(:casino_service_tickets, :ticket)
|
41
|
+
add_index :casino_service_tickets, :ticket, :unique => true
|
42
|
+
end
|
43
|
+
unless index_exists?(:casino_service_tickets, :ticket_granting_ticket_id)
|
44
|
+
add_index :casino_service_tickets, :ticket_granting_ticket_id
|
45
|
+
end
|
46
|
+
|
47
|
+
# Ticket Granting Tickets
|
48
|
+
rename_table :ticket_granting_tickets, :casino_ticket_granting_tickets
|
49
|
+
unless index_exists?(:casino_ticket_granting_tickets, :ticket)
|
50
|
+
add_index :casino_ticket_granting_tickets, :ticket, :unique => true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Two-Factor Authenticators
|
54
|
+
rename_table :two_factor_authenticators, :casino_two_factor_authenticators
|
55
|
+
unless index_exists?(:casino_two_factor_authenticators, :user_id)
|
56
|
+
add_index :casino_two_factor_authenticators, :user_id
|
57
|
+
end
|
58
|
+
|
59
|
+
# Users
|
60
|
+
rename_table :users, :casino_users
|
61
|
+
unless index_exists?(:casino_users, [:authenticator, :username])
|
62
|
+
add_index :casino_users, [:authenticator, :username], :unique => true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def down
|
67
|
+
remove_index :casino_login_tickets, :ticket
|
68
|
+
drop_table :casino_login_tickets
|
69
|
+
|
70
|
+
# Proxy Granting Tickets
|
71
|
+
remove_index :casino_proxy_granting_tickets, :ticket, :unique => true
|
72
|
+
remove_index :casino_proxy_granting_tickets, :iou, :unique => true
|
73
|
+
remove_index :casino_proxy_granting_tickets, [:granter_type, :granter_id], :name => "index_casino_proxy_granting_tickets_on_granter", :unique => true
|
74
|
+
drop_table :casino_proxy_granting_tickets
|
75
|
+
|
76
|
+
# Proxy Tickets
|
77
|
+
remove_index :casino_proxy_tickets, :ticket, :unique => true
|
78
|
+
remove_index :casino_proxy_tickets, :proxy_granting_ticket_id
|
79
|
+
drop_table :casino_proxy_tickets
|
80
|
+
|
81
|
+
# Service Rules
|
82
|
+
remove_index :casino_service_rules, :url, :unique => true
|
83
|
+
drop_table :casino_service_rules
|
84
|
+
|
85
|
+
# Service Tickets
|
86
|
+
remove_index :casino_service_tickets, :ticket, :unique => true
|
87
|
+
remove_index :casino_service_tickets, :ticket_granting_ticket_id
|
88
|
+
drop_table :casino_service_tickets
|
89
|
+
|
90
|
+
# Ticket Granting Tickets
|
91
|
+
remove_index :casino_ticket_granting_tickets, :ticket, :unique => true
|
92
|
+
drop_table :casino_ticket_granting_tickets
|
93
|
+
|
94
|
+
# Two-Factor Authenticators
|
95
|
+
remove_index :casino_two_factor_authenticators, :user_id
|
96
|
+
drop_table :casino_two_factor_authenticators
|
97
|
+
|
98
|
+
# Users
|
99
|
+
remove_index :casino_users, [:authenticator, :username], :unique => true
|
100
|
+
drop_table :casino_users
|
101
|
+
end
|
102
|
+
end
|