redis-rack 2.1.0.pre → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f58690fddef5788f2c9b9297969f1ad812278554aca17f40842b163a6362f1bc
4
- data.tar.gz: e89fb1293e5cc06955ab50138d27e7766d7a07691916ae351347ef29b43751d3
3
+ metadata.gz: bd358598a3b5173b0af0e6af5a0eb8544d33beb746a24c0d4ae01cb01e5e82c1
4
+ data.tar.gz: 9afa606f06fc3a5b6812ac5d5a961bc440df74b2ac27160a03536fa0f69d7474
5
5
  SHA512:
6
- metadata.gz: 5263c92df2caeadca08bcc303a8454965f1aca30d48f958bfb0773f5af52f866b51d1cf6ce5d7850737036fe486e8dd20d2aeb45e550a088db600295515cd5d3
7
- data.tar.gz: 0312052d9285c9cef39ab3857d13c42df7023d494fb4392112bc1fce475fd905f51beaf253f337abab07d6d013dce7f32af5c5a1c4cd749fb744e9928ce7d36b
6
+ metadata.gz: a88c2a36dca22320e1e8d015fbfd0ece8b71f814c60e7a90cb1036ae8cee9f713f3321389f286c707b982a5a82c8b5078ffe93b58c37e17367fec6aa8544e209
7
+ data.tar.gz: 41722398d1973c7390155fb71c9fe17e3e99e1b0093db1b7d588c77dec01487390b4208a8e04ff0a8050d0f03029c606d619e68da7cbfed9e3bdf397159c0502
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  script: bundle exec rake
3
3
  rvm:
4
- - 2.2.3
5
- - 2.3.1
4
+ - 2.2
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+ - 2.7
6
10
  - ruby-head
7
11
  - jruby-head
8
12
  matrix:
@@ -5,10 +5,10 @@ require 'redis/rack/connection'
5
5
 
6
6
  module Rack
7
7
  module Session
8
- class Redis < Abstract::Persisted
8
+ class Redis < Abstract::PersistedSecure
9
9
  attr_reader :mutex
10
10
 
11
- DEFAULT_OPTIONS = Abstract::Persisted::DEFAULT_OPTIONS.merge(
11
+ DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge(
12
12
  :redis_server => 'redis://127.0.0.1:6379/0/rack:session'
13
13
  )
14
14
 
@@ -24,7 +24,7 @@ module Rack
24
24
  loop do
25
25
  sid = generate_sid
26
26
  first = with do |c|
27
- [*c.setnx(sid, session, @default_options)].first
27
+ [*c.setnx(sid.private_id, session, @default_options)].first
28
28
  end
29
29
  break sid if [1, true].include?(first)
30
30
  end
@@ -35,7 +35,7 @@ module Rack
35
35
  [generate_sid, {}]
36
36
  else
37
37
  with_lock(req, [nil, {}]) do
38
- unless sid and session = with { |c| c.get(sid) }
38
+ unless sid and session = get_session_with_fallback(sid)
39
39
  session = {}
40
40
  sid = generate_unique_sid(session)
41
41
  end
@@ -44,16 +44,19 @@ module Rack
44
44
  end
45
45
  end
46
46
 
47
- def write_session(req, session_id, new_session, options)
47
+ def write_session(req, sid, new_session, options)
48
48
  with_lock(req, false) do
49
- with { |c| c.set session_id, new_session, options }
50
- session_id
49
+ with { |c| c.set sid.private_id, new_session, options }
50
+ sid
51
51
  end
52
52
  end
53
53
 
54
- def delete_session(req, session_id, options)
54
+ def delete_session(req, sid, options)
55
55
  with_lock(req) do
56
- with { |c| c.del(session_id) }
56
+ with do |c|
57
+ c.del(sid.public_id)
58
+ c.del(sid.private_id)
59
+ end
57
60
  generate_sid unless options[:drop]
58
61
  end
59
62
  end
@@ -78,6 +81,12 @@ module Rack
78
81
  def with(&block)
79
82
  @conn.with(&block)
80
83
  end
84
+
85
+ private
86
+
87
+ def get_session_with_fallback(sid)
88
+ with { |c| c.get(sid.private_id) || c.get(sid.public_id) }
89
+ end
81
90
  end
82
91
  end
83
92
  end
@@ -1,6 +1,5 @@
1
1
  class Redis
2
2
  module Rack
3
- VERSION = '2.1.0.pre'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
6
-
@@ -12,15 +12,13 @@ Gem::Specification.new do |s|
12
12
  s.description = %q{Redis Store for Rack applications}
13
13
  s.license = 'MIT'
14
14
 
15
- s.rubyforge_project = 'redis-rack'
16
-
17
15
  s.files = `git ls-files`.split("\n")
18
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
  s.executables = []
20
18
  s.require_paths = ["lib"]
21
19
 
22
20
  s.add_runtime_dependency 'redis-store', ['< 2', '>= 1.2']
23
- s.add_runtime_dependency 'rack', '>= 1.5', '< 3'
21
+ s.add_runtime_dependency 'rack', '>= 2.0.8', '< 3'
24
22
 
25
23
  s.add_development_dependency 'rake', '~> 10'
26
24
  s.add_development_dependency 'bundler', '> 1', '< 3'
@@ -93,7 +93,7 @@ describe Rack::Session::Redis do
93
93
  it "does not store a blank session" do
94
94
  session_store = Rack::Session::Redis.new(incrementor)
95
95
  sid = session_store.generate_unique_sid({})
96
- session_store.with { |c| c.get(sid).must_be_nil }
96
+ session_store.with { |c| c.get(sid.private_id).must_be_nil }
97
97
  end
98
98
 
99
99
  it "locks the store mutex" do
@@ -299,10 +299,11 @@ describe Rack::Session::Redis do
299
299
 
300
300
  res0 = req.get("/")
301
301
  session_id = (cookie = res0["Set-Cookie"])[session_match, 1]
302
- ses0 = pool.with { |c| c.get(session_id) }
302
+ sid = Rack::Session::SessionId.new(session_id)
303
+ ses0 = pool.with { |c| c.get(sid.private_id) }
303
304
 
304
305
  req.get("/", "HTTP_COOKIE" => cookie)
305
- ses1 = pool.with { |c| c.get(session_id) }
306
+ ses1 = pool.with { |c| c.get(sid.private_id) }
306
307
 
307
308
  ses1.wont_equal(ses0)
308
309
  end
@@ -322,6 +323,7 @@ describe Rack::Session::Redis do
322
323
  res.body.must_equal('{"counter"=>1}')
323
324
  cookie = res["Set-Cookie"]
324
325
  session_id = cookie[session_match, 1]
326
+ sid = Rack::Session::SessionId.new(session_id)
325
327
 
326
328
  delta_incrementor = lambda do |env|
327
329
  # emulate disconjoinment of threading
@@ -343,7 +345,7 @@ describe Rack::Session::Redis do
343
345
  request.body.must_include('"counter"=>2')
344
346
  end
345
347
 
346
- session = pool.with { |c| c.get(session_id) }
348
+ session = pool.with { |c| c.get(sid.private_id) }
347
349
  session.size.must_equal(tnum+1) # counter
348
350
  session['counter'].must_equal(2) # meeeh
349
351
 
@@ -360,7 +362,7 @@ describe Rack::Session::Redis do
360
362
  request.body.must_include('"counter"=>3')
361
363
  end
362
364
 
363
- session = pool.with { |c| c.get(session_id) }
365
+ session = pool.with { |c| c.get(sid.private_id) }
364
366
  session.size.must_equal(tnum+1)
365
367
  session['counter'].must_equal(3)
366
368
 
@@ -382,7 +384,7 @@ describe Rack::Session::Redis do
382
384
  request.body.must_include('"foo"=>"bar"')
383
385
  end
384
386
 
385
- session = pool.with { |c| c.get(session_id) }
387
+ session = pool.with { |c| c.get(sid.private_id) }
386
388
  session.size.must_equal(r.size+1)
387
389
  session['counter'].must_be_nil
388
390
  session['foo'].must_equal('bar')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.pre
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-store
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '1.5'
39
+ version: 2.0.8
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '1.5'
49
+ version: 2.0.8
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3'
@@ -195,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">"
198
+ - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: 1.3.1
200
+ version: '0'
201
201
  requirements: []
202
202
  rubygems_version: 3.0.3
203
203
  signing_key: