has_global_session 0.8.7 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
data/has_global_session.gemspec
CHANGED
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
8
8
|
|
9
9
|
s.name = 'has_global_session'
|
10
|
-
s.version = '0.8.
|
11
|
-
s.date = '2010-06-
|
10
|
+
s.version = '0.8.9'
|
11
|
+
s.date = '2010-06-29'
|
12
12
|
|
13
13
|
s.authors = ['Tony Spataro']
|
14
14
|
s.email = 'code@tracker.xeger.net'
|
data/lib/has_global_session.rb
CHANGED
@@ -2,6 +2,7 @@ module HasGlobalSession
|
|
2
2
|
class MissingConfiguration < Exception; end
|
3
3
|
class ConfigurationError < Exception; end
|
4
4
|
class InvalidSession < Exception; end
|
5
|
+
class ExpiredSession < Exception; end
|
5
6
|
class UnserializableType < Exception; end
|
6
7
|
class NoAuthority < Exception; end
|
7
8
|
end
|
@@ -171,8 +171,13 @@ module HasGlobalSession
|
|
171
171
|
end
|
172
172
|
|
173
173
|
#Check expiration
|
174
|
+
unless expired_at > Time.now.utc
|
175
|
+
raise ExpiredSession, "Session expired at #{expired_at}"
|
176
|
+
end
|
177
|
+
|
178
|
+
#Check other validity (delegate to directory)
|
174
179
|
unless @directory.valid_session?(id, expired_at)
|
175
|
-
raise InvalidSession, "Global session has
|
180
|
+
raise InvalidSession, "Global session has been invalidated"
|
176
181
|
end
|
177
182
|
|
178
183
|
#If all validation stuff passed, assign our instance variables.
|
@@ -214,7 +219,7 @@ module HasGlobalSession
|
|
214
219
|
|
215
220
|
def create_invalid
|
216
221
|
@id = nil
|
217
|
-
@created_at = Time.now
|
222
|
+
@created_at = Time.now.utc
|
218
223
|
@expired_at = created_at
|
219
224
|
@signed = {}
|
220
225
|
@insecure = {}
|
@@ -57,9 +57,10 @@ module HasGlobalSession
|
|
57
57
|
#Update the cookie only if its value has changed
|
58
58
|
cookies[name] = {:value => value, :domain=>domain, :expires=>expires}
|
59
59
|
end
|
60
|
+
else
|
61
|
+
#No valid session? Write an empty cookie.
|
62
|
+
cookies[name] = {:value=>nil, :domain=>domain, :expires=>Time.at(0)}
|
60
63
|
end
|
61
|
-
|
62
|
-
raise HasGlobalSession::InvalidSession, "buahahaha" if params[:moo]
|
63
64
|
rescue Exception => e
|
64
65
|
#silently recover from any error by wiping the cookie
|
65
66
|
cookies[name] = {:value=>nil, :domain=>domain, :expires=>Time.at(0)}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_global_session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 45
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 9
|
10
|
+
version: 0.8.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Spataro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|