casino_core 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CASinoCore [![Build Status](https://secure.travis-ci.org/rbCAS/CASinoCore.png?branch=master)](https://travis-ci.org/rbCAS/CASinoCore)
1
+ # CASinoCore [![Build Status](https://secure.travis-ci.org/rbCAS/CASinoCore.png?branch=master)](https://travis-ci.org/rbCAS/CASinoCore) [![Coverage Status](https://coveralls.io/repos/rbCAS/CASinoCore/badge.png?branch=master)](https://coveralls.io/r/rbCAS/CASinoCore)
2
2
 
3
3
  A CAS server core library.
4
4
 
@@ -58,9 +58,7 @@ module CASinoCore
58
58
  end
59
59
 
60
60
  def cleanup_expired_ticket_granting_tickets(user)
61
- user.ticket_granting_tickets.where(['created_at < ?', CASinoCore::Settings.ticket_granting_ticket[:lifetime].seconds.ago]).destroy_all.tap do |destroyed|
62
- logger.info "Destroyed #{destroyed.length} expired ticket-granting tickets"
63
- end
61
+ CASinoCore::Model::TicketGrantingTicket.cleanup(user)
64
62
  end
65
63
 
66
64
  end
@@ -7,13 +7,18 @@ class CASinoCore::Model::TicketGrantingTicket < ActiveRecord::Base
7
7
  belongs_to :user
8
8
  has_many :service_tickets, dependent: :destroy
9
9
 
10
- def self.cleanup
11
- self.destroy_all([
10
+ def self.cleanup(user = nil)
11
+ if user.nil?
12
+ base = self
13
+ else
14
+ base = user.ticket_granting_tickets
15
+ end
16
+ base.where([
12
17
  '(created_at < ? AND long_term = ?) OR created_at < ?',
13
18
  CASinoCore::Settings.ticket_granting_ticket[:lifetime].seconds.ago,
14
19
  false,
15
20
  CASinoCore::Settings.ticket_granting_ticket[:lifetime_long_term].seconds.ago
16
- ])
21
+ ]).destroy_all
17
22
  end
18
23
 
19
24
  def browser_info
@@ -36,7 +41,9 @@ class CASinoCore::Model::TicketGrantingTicket < ActiveRecord::Base
36
41
  end
37
42
 
38
43
  def expired?
39
- if long_term?
44
+ if awaiting_two_factor_authentication?
45
+ lifetime = CASinoCore::Settings.two_factor_authenticator[:timeout]
46
+ elsif long_term?
40
47
  lifetime = CASinoCore::Settings.ticket_granting_ticket[:lifetime_long_term]
41
48
  else
42
49
  lifetime = CASinoCore::Settings.ticket_granting_ticket[:lifetime]
@@ -24,6 +24,7 @@ module CASinoCore
24
24
  lifetime_consumed: 86400
25
25
  },
26
26
  two_factor_authenticator: {
27
+ timeout: 180,
27
28
  lifetime_inactive: 300,
28
29
  drift: 30
29
30
  }
@@ -1,3 +1,3 @@
1
1
  module CASinoCore
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -125,6 +125,30 @@ describe CASinoCore::Model::TicketGrantingTicket do
125
125
  ticket_granting_ticket.expired?.should == false
126
126
  end
127
127
  end
128
+
129
+ context 'with pending two-factor authentication' do
130
+ before(:each) do
131
+ ticket_granting_ticket.awaiting_two_factor_authentication = true
132
+ ticket_granting_ticket.save!
133
+ end
134
+
135
+ context 'with an expired ticket' do
136
+ before(:each) do
137
+ ticket_granting_ticket.created_at = 10.minutes.ago
138
+ ticket_granting_ticket.save!
139
+ end
140
+
141
+ it 'returns true' do
142
+ ticket_granting_ticket.expired?.should == true
143
+ end
144
+ end
145
+
146
+ context 'with an unexpired ticket' do
147
+ it 'returns false' do
148
+ ticket_granting_ticket.expired?.should == false
149
+ end
150
+ end
151
+ end
128
152
  end
129
153
 
130
154
  describe '.cleanup' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casino_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  b1VSdnUwRzgvWXlIVUFtSVUvV0tyanIxYmdjZjFWUnYKUjRLRDFNblVWL3Y1
37
37
  MDJwaU1sWG1qeE9XZGJLOHl2UUVIa3N1L3pqYkNqU3UrTTJrd0ZtV0dzeDVu
38
38
  eCtWZHc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2013-03-24 00:00:00.000000000 Z
39
+ date: 2013-03-26 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
@@ -313,7 +313,6 @@ files:
313
313
  - README.md
314
314
  - Rakefile
315
315
  - UPGRADE.md
316
- - VERSION
317
316
  - casino-public_cert.pem
318
317
  - casino_core.gemspec
319
318
  - config/cas.yml
@@ -448,21 +447,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
448
447
  - - ! '>='
449
448
  - !ruby/object:Gem::Version
450
449
  version: '0'
451
- segments:
452
- - 0
453
- hash: -3391276428784871857
454
450
  required_rubygems_version: !ruby/object:Gem::Requirement
455
451
  none: false
456
452
  requirements:
457
453
  - - ! '>='
458
454
  - !ruby/object:Gem::Version
459
455
  version: '0'
460
- segments:
461
- - 0
462
- hash: -3391276428784871857
463
456
  requirements: []
464
457
  rubyforge_project:
465
- rubygems_version: 1.8.25
458
+ rubygems_version: 1.8.24
466
459
  signing_key:
467
460
  specification_version: 3
468
461
  summary: A CAS server core library.
metadata.gz.sig CHANGED
Binary file
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.9