casino 4.0.3 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/stylesheets/casino.scss +60 -1
- data/app/controllers/casino/login_attempts_controller.rb +10 -0
- data/app/controllers/casino/sessions_controller.rb +3 -0
- data/app/helpers/casino/sessions_helper.rb +14 -0
- data/app/models/casino/login_attempt.rb +11 -0
- data/app/models/casino/model_concern/browser_info.rb +14 -0
- data/app/models/casino/ticket_granting_ticket.rb +1 -11
- data/app/models/casino/user.rb +1 -0
- data/app/views/casino/kaminari/_next_page.html.erb +5 -0
- data/app/views/casino/kaminari/_paginator.html.erb +6 -0
- data/app/views/casino/kaminari/_prev_page.html.erb +5 -0
- data/app/views/casino/login_attempts/_table.html.erb +28 -0
- data/app/views/casino/login_attempts/index.html.erb +14 -0
- data/app/views/casino/sessions/index.html.erb +12 -5
- data/casino.gemspec +1 -0
- data/config/locales/de.yml +34 -0
- data/config/locales/en.yml +35 -1
- data/config/locales/fr.yml +16 -0
- data/config/locales/pt-BR.yml +16 -0
- data/config/locales/ru.yml +110 -0
- data/config/locales/zh-CN.yml +16 -0
- data/config/locales/zh-TW.yml +16 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20160502074450_create_login_attempts.rb +14 -0
- data/lib/casino/engine.rb +1 -0
- data/lib/casino/version.rb +1 -1
- data/spec/controllers/login_attempts_controller_spec.rb +35 -0
- data/spec/controllers/sessions_controller_spec.rb +121 -68
- data/spec/dummy/db/schema.rb +11 -2
- data/spec/features/login_attempts_spec.rb +24 -0
- data/spec/features/session_overview_spec.rb +12 -0
- data/spec/model/login_attempt_spec.rb +7 -0
- data/spec/model/ticket_granting_ticket_spec.rb +5 -29
- data/spec/support/factories/login_attempt_factory.rb +10 -0
- data/spec/support/has_browser_info.rb +29 -0
- data/spec/support/kaminari.rb +3 -0
- metadata +38 -2
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160502074450) do
|
15
15
|
|
16
16
|
create_table "casino_auth_token_tickets", force: true do |t|
|
17
17
|
t.string "ticket", null: false
|
@@ -21,6 +21,15 @@ ActiveRecord::Schema.define(version: 20151026130743) do
|
|
21
21
|
|
22
22
|
add_index "casino_auth_token_tickets", ["ticket"], name: "index_casino_auth_token_tickets_on_ticket", unique: true
|
23
23
|
|
24
|
+
create_table "casino_login_attempts", force: true do |t|
|
25
|
+
t.integer "user_id", null: false
|
26
|
+
t.boolean "successful", default: false
|
27
|
+
t.string "user_ip"
|
28
|
+
t.text "user_agent"
|
29
|
+
t.datetime "created_at"
|
30
|
+
t.datetime "updated_at"
|
31
|
+
end
|
32
|
+
|
24
33
|
create_table "casino_login_tickets", force: true do |t|
|
25
34
|
t.string "ticket", null: false
|
26
35
|
t.datetime "created_at"
|
@@ -87,9 +96,9 @@ ActiveRecord::Schema.define(version: 20151026130743) do
|
|
87
96
|
t.integer "user_id", null: false
|
88
97
|
t.boolean "awaiting_two_factor_authentication", default: false, null: false
|
89
98
|
t.boolean "long_term", default: false, null: false
|
99
|
+
t.string "user_ip"
|
90
100
|
t.datetime "created_at"
|
91
101
|
t.datetime "updated_at"
|
92
|
-
t.string "user_ip"
|
93
102
|
end
|
94
103
|
|
95
104
|
add_index "casino_ticket_granting_tickets", ["ticket"], name: "index_casino_ticket_granting_tickets_on_ticket", unique: true
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Session overview' do
|
4
|
+
include CASino::Engine.routes.url_helpers
|
5
|
+
|
6
|
+
subject { page }
|
7
|
+
|
8
|
+
context 'when logged in' do
|
9
|
+
let(:login_attempt) do
|
10
|
+
FactoryGirl.create :login_attempt, created_at: Time.zone.parse('2015-01-01 09:10'),
|
11
|
+
user: CASino::User.first
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
sign_in
|
16
|
+
login_attempt.touch
|
17
|
+
visit login_attempts_path
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should have_text('TestBrowser') }
|
21
|
+
it { should have_text('133.133.133.133') }
|
22
|
+
it { should have_text('2015-01-01 09:10') }
|
23
|
+
end
|
24
|
+
end
|
@@ -6,8 +6,14 @@ describe 'Session overview' do
|
|
6
6
|
subject { page }
|
7
7
|
|
8
8
|
context 'when logged in' do
|
9
|
+
let(:login_attempt) do
|
10
|
+
FactoryGirl.create :login_attempt, created_at: Time.zone.parse('2015-01-01 09:10'),
|
11
|
+
user: CASino::User.first
|
12
|
+
end
|
13
|
+
|
9
14
|
before do
|
10
15
|
sign_in
|
16
|
+
login_attempt.touch
|
11
17
|
visit sessions_path
|
12
18
|
end
|
13
19
|
|
@@ -19,6 +25,12 @@ describe 'Session overview' do
|
|
19
25
|
it { should_not have_button('End session') }
|
20
26
|
end
|
21
27
|
|
28
|
+
context 'with login attempts' do
|
29
|
+
it { should have_text('TestBrowser') }
|
30
|
+
it { should have_text('133.133.133.133') }
|
31
|
+
it { should have_text('2015-01-01 09:10') }
|
32
|
+
end
|
33
|
+
|
22
34
|
context 'when other sessions exist' do
|
23
35
|
before do
|
24
36
|
in_browser(:other) do
|
@@ -2,9 +2,13 @@ require 'spec_helper'
|
|
2
2
|
require 'useragent'
|
3
3
|
|
4
4
|
describe CASino::TicketGrantingTicket do
|
5
|
-
let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }
|
5
|
+
let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket, user_agent: 'TestBrowser' }
|
6
6
|
let(:service_ticket) { FactoryGirl.create :service_ticket, ticket_granting_ticket: ticket_granting_ticket }
|
7
7
|
|
8
|
+
subject { ticket_granting_ticket }
|
9
|
+
|
10
|
+
it_behaves_like 'has browser info'
|
11
|
+
|
8
12
|
describe '#destroy' do
|
9
13
|
let!(:consumed_service_ticket) { FactoryGirl.create :service_ticket, :consumed, ticket_granting_ticket: ticket_granting_ticket }
|
10
14
|
|
@@ -33,35 +37,7 @@ describe CASino::TicketGrantingTicket do
|
|
33
37
|
it 'returns request remote_ip' do
|
34
38
|
ticket_granting_ticket.user_ip.should == '127.0.0.1'
|
35
39
|
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#browser_info' do
|
40
|
-
let(:user_agent) { Object.new }
|
41
|
-
before(:each) do
|
42
|
-
user_agent.stub(:browser).and_return('TestBrowser')
|
43
|
-
UserAgent.stub(:parse).and_return(user_agent)
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'without platform' do
|
47
|
-
before(:each) do
|
48
|
-
user_agent.stub(:platform).and_return(nil)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns the browser name' do
|
52
|
-
ticket_granting_ticket.browser_info.should == 'TestBrowser'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with a platform' do
|
57
|
-
before(:each) do
|
58
|
-
user_agent.stub(:platform).and_return('Linux')
|
59
|
-
end
|
60
40
|
|
61
|
-
it 'returns the browser name' do
|
62
|
-
ticket_granting_ticket.browser_info.should == 'TestBrowser (Linux)'
|
63
|
-
end
|
64
|
-
end
|
65
41
|
end
|
66
42
|
|
67
43
|
describe '#same_user?' do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
shared_examples 'has browser info' do
|
2
|
+
describe '#browser_info' do
|
3
|
+
let(:user_agent) { Object.new }
|
4
|
+
before(:each) do
|
5
|
+
user_agent.stub(:browser).and_return('TestBrowser')
|
6
|
+
UserAgent.stub(:parse).and_return(user_agent)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'without platform' do
|
10
|
+
before(:each) do
|
11
|
+
user_agent.stub(:platform).and_return(nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the browser name' do
|
15
|
+
subject.browser_info.should == 'TestBrowser'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with a platform' do
|
20
|
+
before(:each) do
|
21
|
+
user_agent.stub(:platform).and_return('Linux')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the browser name' do
|
25
|
+
subject.browser_info.should == 'TestBrowser (Linux)'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nils Caspar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: capybara
|
@@ -290,6 +290,20 @@ dependencies:
|
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0.1'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: kaminari
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "~>"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '0.16'
|
300
|
+
type: :runtime
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "~>"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0.16'
|
293
307
|
description: CASino is a simple CAS (Central Authentication Service) server.
|
294
308
|
email:
|
295
309
|
- ncaspar@me.com
|
@@ -330,6 +344,7 @@ files:
|
|
330
344
|
- app/controllers/casino/application_controller.rb
|
331
345
|
- app/controllers/casino/auth_tokens_controller.rb
|
332
346
|
- app/controllers/casino/controller_concern/ticket_validator.rb
|
347
|
+
- app/controllers/casino/login_attempts_controller.rb
|
333
348
|
- app/controllers/casino/proxy_tickets_controller.rb
|
334
349
|
- app/controllers/casino/service_tickets_controller.rb
|
335
350
|
- app/controllers/casino/sessions_controller.rb
|
@@ -338,7 +353,9 @@ files:
|
|
338
353
|
- app/helpers/casino/sessions_helper.rb
|
339
354
|
- app/helpers/casino/two_factor_authenticators_helper.rb
|
340
355
|
- app/models/casino/auth_token_ticket.rb
|
356
|
+
- app/models/casino/login_attempt.rb
|
341
357
|
- app/models/casino/login_ticket.rb
|
358
|
+
- app/models/casino/model_concern/browser_info.rb
|
342
359
|
- app/models/casino/model_concern/consumable_ticket.rb
|
343
360
|
- app/models/casino/model_concern/ticket.rb
|
344
361
|
- app/models/casino/proxy_granting_ticket.rb
|
@@ -359,6 +376,11 @@ files:
|
|
359
376
|
- app/services/casino/auth_token_validation_service.rb
|
360
377
|
- app/views/casino/application/_footer.html.erb
|
361
378
|
- app/views/casino/application/_messages.html.erb
|
379
|
+
- app/views/casino/kaminari/_next_page.html.erb
|
380
|
+
- app/views/casino/kaminari/_paginator.html.erb
|
381
|
+
- app/views/casino/kaminari/_prev_page.html.erb
|
382
|
+
- app/views/casino/login_attempts/_table.html.erb
|
383
|
+
- app/views/casino/login_attempts/index.html.erb
|
362
384
|
- app/views/casino/service_tickets/validate.text.erb
|
363
385
|
- app/views/casino/sessions/index.html.erb
|
364
386
|
- app/views/casino/sessions/logout.html.erb
|
@@ -379,6 +401,7 @@ files:
|
|
379
401
|
- config/locales/en.yml
|
380
402
|
- config/locales/fr.yml
|
381
403
|
- config/locales/pt-BR.yml
|
404
|
+
- config/locales/ru.yml
|
382
405
|
- config/locales/zh-CN.yml
|
383
406
|
- config/locales/zh-TW.yml
|
384
407
|
- config/routes.rb
|
@@ -391,6 +414,7 @@ files:
|
|
391
414
|
- db/migrate/20140827183611_fix_length_of_text_fields.rb
|
392
415
|
- db/migrate/20140831205255_create_auth_token_tickets.rb
|
393
416
|
- db/migrate/20151022192752_add_user_ip_to_ticket_granting_ticket.rb
|
417
|
+
- db/migrate/20160502074450_create_login_attempts.rb
|
394
418
|
- lib/assets/.gitkeep
|
395
419
|
- lib/casino.rb
|
396
420
|
- lib/casino/authenticator.rb
|
@@ -418,6 +442,7 @@ files:
|
|
418
442
|
- spec/authenticator/base_spec.rb
|
419
443
|
- spec/authenticator/static_spec.rb
|
420
444
|
- spec/controllers/auth_tokens_controller_spec.rb
|
445
|
+
- spec/controllers/login_attempts_controller_spec.rb
|
421
446
|
- spec/controllers/proxy_tickets_controller_spec.rb
|
422
447
|
- spec/controllers/service_and_proxy_tickets_controller_spec.rb
|
423
448
|
- spec/controllers/service_tickets_controller_spec.rb
|
@@ -467,11 +492,13 @@ files:
|
|
467
492
|
- spec/dummy/public/500.html
|
468
493
|
- spec/dummy/public/favicon.ico
|
469
494
|
- spec/dummy/script/rails
|
495
|
+
- spec/features/login_attempts_spec.rb
|
470
496
|
- spec/features/login_spec.rb
|
471
497
|
- spec/features/logout_spec.rb
|
472
498
|
- spec/features/session_overview_spec.rb
|
473
499
|
- spec/features/two_factor_authenticator_spec.rb
|
474
500
|
- spec/model/auth_token_ticket_spec.rb
|
501
|
+
- spec/model/login_attempt_spec.rb
|
475
502
|
- spec/model/login_ticket_spec.rb
|
476
503
|
- spec/model/proxy_ticket_spec.rb
|
477
504
|
- spec/model/service_rule_spec.rb
|
@@ -483,6 +510,7 @@ files:
|
|
483
510
|
- spec/spec_helper.rb
|
484
511
|
- spec/support/.gitkeep
|
485
512
|
- spec/support/casino.rb
|
513
|
+
- spec/support/factories/login_attempt_factory.rb
|
486
514
|
- spec/support/factories/login_ticket_factory.rb
|
487
515
|
- spec/support/factories/proxy_granting_ticket_factory.rb
|
488
516
|
- spec/support/factories/proxy_ticket_factory.rb
|
@@ -492,6 +520,8 @@ files:
|
|
492
520
|
- spec/support/factories/two_factor_authenticator_factory.rb
|
493
521
|
- spec/support/factories/user_factory.rb
|
494
522
|
- spec/support/features_helper.rb
|
523
|
+
- spec/support/has_browser_info.rb
|
524
|
+
- spec/support/kaminari.rb
|
495
525
|
- spec/support/rspec.rb
|
496
526
|
- spec/support/sign_in.rb
|
497
527
|
- spec/support/sqlite3.rb
|
@@ -525,6 +555,7 @@ test_files:
|
|
525
555
|
- spec/authenticator/base_spec.rb
|
526
556
|
- spec/authenticator/static_spec.rb
|
527
557
|
- spec/controllers/auth_tokens_controller_spec.rb
|
558
|
+
- spec/controllers/login_attempts_controller_spec.rb
|
528
559
|
- spec/controllers/proxy_tickets_controller_spec.rb
|
529
560
|
- spec/controllers/service_and_proxy_tickets_controller_spec.rb
|
530
561
|
- spec/controllers/service_tickets_controller_spec.rb
|
@@ -574,11 +605,13 @@ test_files:
|
|
574
605
|
- spec/dummy/public/500.html
|
575
606
|
- spec/dummy/public/favicon.ico
|
576
607
|
- spec/dummy/script/rails
|
608
|
+
- spec/features/login_attempts_spec.rb
|
577
609
|
- spec/features/login_spec.rb
|
578
610
|
- spec/features/logout_spec.rb
|
579
611
|
- spec/features/session_overview_spec.rb
|
580
612
|
- spec/features/two_factor_authenticator_spec.rb
|
581
613
|
- spec/model/auth_token_ticket_spec.rb
|
614
|
+
- spec/model/login_attempt_spec.rb
|
582
615
|
- spec/model/login_ticket_spec.rb
|
583
616
|
- spec/model/proxy_ticket_spec.rb
|
584
617
|
- spec/model/service_rule_spec.rb
|
@@ -590,6 +623,7 @@ test_files:
|
|
590
623
|
- spec/spec_helper.rb
|
591
624
|
- spec/support/.gitkeep
|
592
625
|
- spec/support/casino.rb
|
626
|
+
- spec/support/factories/login_attempt_factory.rb
|
593
627
|
- spec/support/factories/login_ticket_factory.rb
|
594
628
|
- spec/support/factories/proxy_granting_ticket_factory.rb
|
595
629
|
- spec/support/factories/proxy_ticket_factory.rb
|
@@ -599,6 +633,8 @@ test_files:
|
|
599
633
|
- spec/support/factories/two_factor_authenticator_factory.rb
|
600
634
|
- spec/support/factories/user_factory.rb
|
601
635
|
- spec/support/features_helper.rb
|
636
|
+
- spec/support/has_browser_info.rb
|
637
|
+
- spec/support/kaminari.rb
|
602
638
|
- spec/support/rspec.rb
|
603
639
|
- spec/support/sign_in.rb
|
604
640
|
- spec/support/sqlite3.rb
|