rack-session 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/session/abstract/id.rb +1 -1
- data/lib/rack/session/cookie.rb +26 -25
- data/lib/rack/session/encryptor.rb +1 -1
- data/lib/rack/session/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f1782c9cc160cdbcee7ac400f1d3643c5b2140e6024c5a1e9829df9d535441
|
4
|
+
data.tar.gz: cacc044559ef38fef31477da4e17173de8533e5970739e7bfc90678d38bf08e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b196f3055fdb3ccda5e0aff1a0aa3b852e1fb3676de3ed0508f2d92f2771e63c8b79ac8b3b7dc4c346467eadd178786e31b92501fb900418be6c7d0afe985de
|
7
|
+
data.tar.gz: 9d200ef0353f8efdf0a92f072db2765fd2be3cd391db47a603c31be9f0a29b16dfb421e20693e889c38204171680fc5f859046d823fe4aaf0a6a6f26300b25b4
|
data/lib/rack/session/cookie.rb
CHANGED
@@ -202,39 +202,40 @@ module Rack
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def extract_session_id(request)
|
205
|
-
unpacked_cookie_data(request)["session_id"
|
205
|
+
unpacked_cookie_data(request)&.[]("session_id")
|
206
206
|
end
|
207
207
|
|
208
208
|
def unpacked_cookie_data(request)
|
209
209
|
request.fetch_header(RACK_SESSION_UNPACKED_COOKIE_DATA) do |k|
|
210
|
-
cookie_data = request.cookies[@key]
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
210
|
+
if cookie_data = request.cookies[@key]
|
211
|
+
session_data = nil
|
212
|
+
|
213
|
+
# Try to decrypt the session data with our encryptors
|
214
|
+
encryptors.each do |encryptor|
|
215
|
+
begin
|
216
|
+
session_data = encryptor.decrypt(cookie_data)
|
217
|
+
break
|
218
|
+
rescue Rack::Session::Encryptor::Error => error
|
219
|
+
request.env[Rack::RACK_ERRORS].puts "Session cookie encryptor error: #{error.message}"
|
220
|
+
|
221
|
+
next
|
222
|
+
end
|
222
223
|
end
|
223
|
-
end
|
224
224
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
225
|
+
# If session decryption fails but there is @legacy_hmac_secret
|
226
|
+
# defined, attempt legacy HMAC verification
|
227
|
+
if !session_data && @legacy_hmac_secret
|
228
|
+
# Parse and verify legacy HMAC session cookie
|
229
|
+
session_data, _, digest = cookie_data.rpartition('--')
|
230
|
+
session_data = nil unless legacy_digest_match?(session_data, digest)
|
231
231
|
|
232
|
-
|
233
|
-
|
232
|
+
# Decode using legacy HMAC decoder
|
233
|
+
session_data = @legacy_hmac_coder.decode(session_data)
|
234
234
|
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
elsif !session_data && coder
|
236
|
+
# Use the coder option, which has the potential to be very unsafe
|
237
|
+
session_data = coder.decode(cookie_data)
|
238
|
+
end
|
238
239
|
end
|
239
240
|
|
240
241
|
request.set_header(k, session_data || {})
|
@@ -26,7 +26,7 @@ module Rack
|
|
26
26
|
# Options may include:
|
27
27
|
# * :serialize_json
|
28
28
|
# Use JSON for message serialization instead of Marshal. This can be
|
29
|
-
# viewed as a security
|
29
|
+
# viewed as a security enhancement.
|
30
30
|
# * :pad_size
|
31
31
|
# Pad encrypted message data, to a multiple of this many bytes
|
32
32
|
# (default: 32). This can be between 2-4096 bytes, or +nil+ to disable
|
data/lib/rack/session/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rack Contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
130
|
+
rubygems_version: 3.4.0.dev
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: A session implementation for Rack.
|