redis-rack 2.1.0.pre → 2.1.4

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: e8fe2b21455a3af95982db86314846abed8b97be35712009a6c720b1fe8a0e3f
4
+ data.tar.gz: 99c15862e3d1e7c1d16d460da299fcc0dc551a606ce9731710f153f51f3b6196
5
5
  SHA512:
6
- metadata.gz: 5263c92df2caeadca08bcc303a8454965f1aca30d48f958bfb0773f5af52f866b51d1cf6ce5d7850737036fe486e8dd20d2aeb45e550a088db600295515cd5d3
7
- data.tar.gz: 0312052d9285c9cef39ab3857d13c42df7023d494fb4392112bc1fce475fd905f51beaf253f337abab07d6d013dce7f32af5c5a1c4cd749fb744e9928ce7d36b
6
+ metadata.gz: ef8ef0c5c0286d5df01ee90df055e19ef90969f11b0568a681e64f1955558837584504c5a1b62c8cfc5e7b6fead33cdfa39741f8048ecf787457cb85c7910e6d
7
+ data.tar.gz: e3f5a9642b8f50e9da6cc05f9387d7acca8245bd702e8f795690b383b6fe253ec037ab930e68a282c37e32f139956e00e6a9a5137dae5957cb03e332cfe057a4
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.2
1
+ 2.7.1
data/.travis.yml CHANGED
@@ -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:
data/CHANGELOG.md ADDED
@@ -0,0 +1,246 @@
1
+ v2.1.0 (2020-01-13)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Update version to v2.1.0 final
5
+ Tom Scott
6
+
7
+ * Test against most recent versions of Ruby
8
+ Tom Scott
9
+
10
+ * Update gemspec to remove rubyforge_project
11
+
12
+ It is deprecated or removed already
13
+
14
+ Original warning message:
15
+ Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
16
+ PikachuEXE
17
+
18
+ * back tests to original state
19
+ Alexey Vasiliev
20
+
21
+ * Fix redis-rack for rack 2.0.8, small improvements
22
+ Alexey Vasiliev
23
+
24
+ * Fix redis-rack for rack 2.0.8, fix generate_unique_sid
25
+ Alexey Vasiliev
26
+
27
+ * Fix redis-rack for rack 2.0.8
28
+ Alexey Vasiliev
29
+
30
+ * v2.1.0.pre: Update Rack Session API, drop support for Rack 1.0
31
+ Tom Scott
32
+
33
+ v2.0.6
34
+ --------------------------------------------------------------------------------
35
+
36
+ * v2.0.6: Prevent Connection Pool from passing nil options
37
+ Tom Scott
38
+
39
+ * Make bundler dependency more permissive to support future ruby versions
40
+ Tom Scott
41
+
42
+ * Drop support for Rack v1
43
+ Tom Scott
44
+
45
+ * Update Rack::Session API Compatibility
46
+
47
+ The latest version of Rack [deprecated subclassing Rack::Session::ID](https://github.com/rack/rack/blob/master/lib/rack/session/abstract/id.rb#L412-L419),
48
+ replacing it instead with `Rack::Session::Persisted`. Update the method
49
+ implementations in this gem to support the new API. Shoutouts to @onk
50
+ for actually writing this code, we're pulling it in from his fork.
51
+ Tom Scott
52
+
53
+ * Automatically assign issues to @tubbo when they are created
54
+ Tom Scott
55
+
56
+ * Automatically release to RubyGems when new tags are pushed to GitHub
57
+ Tom Scott
58
+
59
+ * Raise Error when `:redis_store` is Incorrect Type
60
+
61
+ Passing an object that isn't a `Redis::Store` into the session storage
62
+ configuration can cause errors when methods are called with more
63
+ arguments than the default Redis client can handle. These additional
64
+ arguments are used by `Rack::Session::Redis` to configure the key
65
+ namespace and TTL globally in the main configuration, and pass them down
66
+ to `Redis::Store` to be appended to the key. An `ArgumentError` will now
67
+ be thrown when a `:redis_store` is of a type that isn't a `Redis::Store`
68
+ (or a subclass thereof).
69
+
70
+ Resolves #46
71
+ Tom Scott
72
+
73
+ * Add code owners
74
+ Tom Scott
75
+
76
+ * Do not provide nil values for missing connection pool options
77
+
78
+ Fixes #44
79
+ Jake Goulding
80
+
81
+ v2.0.5
82
+ --------------------------------------------------------------------------------
83
+
84
+ * v2.0.5 release
85
+ Tom Scott
86
+
87
+ * add spec to validate blank sessions are not stored in redis
88
+ mstruve
89
+
90
+ * dont store a blank session in redis
91
+ mstruve
92
+
93
+ * Add documentation for options
94
+ Daniel M Barlow
95
+
96
+ v2.0.4
97
+ --------------------------------------------------------------------------------
98
+
99
+ * Release 2.0.4
100
+ Tom Scott
101
+
102
+ * Remove .ruby-version
103
+ Tom Scott
104
+
105
+ * Remove rake, appraisal from gemspec executables
106
+
107
+ The contents of the bin directory are binstubs to assist development.
108
+ They are not intended to be shipped with the gem itself. This commit
109
+ updates the gemspec to ensure that they are not exposed to rubygems as
110
+ executables for redis-rack, which will fix conflicts with the legitimate
111
+ rake and appraisal executables provided by those other gems.
112
+ Matt Brictson
113
+
114
+ v2.0.3
115
+ --------------------------------------------------------------------------------
116
+
117
+ * v2.0.3: Avoid mutex locking with global option
118
+ Tom Scott
119
+
120
+ * Restore default_options in #generate_unique_sid
121
+ Tom Scott
122
+
123
+ * Refactor connection_pool code
124
+
125
+ Adds a `Redis::Rack::Connection` object for handling the instantiation
126
+ of a `Redis::Store` or a `ConnectionPool` if pool configuration is
127
+ given. Restores the purpose of `Rack::Session::Redis` to only implement
128
+ the session ID abstract API provided by Rack.
129
+ Tom Scott
130
+
131
+ * Rename :use_global_lock option to :threadsafe to match Rails
132
+ Garrett Thornburg
133
+
134
+ * Use mocha mocks to assert the mutex is never locked
135
+ Garrett Thornburg
136
+
137
+ * Allow redis-store v1.4
138
+ Shane O'Grady
139
+
140
+ * Create a :use_global_lock option that avoids the global lock
141
+ Garrett Thornburg
142
+
143
+ * Rake task for running all tests on all gem versions
144
+ Tom Scott
145
+
146
+ * Install Appraisal so we can test against multiple versions of Rack
147
+ Tom Scott
148
+
149
+ v2.0.2
150
+ --------------------------------------------------------------------------------
151
+
152
+ * v2.0.2: Resolve regression forcing Rack 2.x and above
153
+ Tom Scott
154
+
155
+ v2.0.1
156
+ --------------------------------------------------------------------------------
157
+
158
+ * v2.0.1: Relax gem dependencies
159
+ Tom Scott
160
+
161
+ * smoothen redis-store dependency
162
+ Mathieu Jobin
163
+
164
+ * Drop support for Rubinius 1.9 mode
165
+
166
+ 1.9.x is EOL in MRI Ruby Land, and Rubinius 1.9 mode isn't really used
167
+ much anymore. This should make the builds pass again.
168
+ Tom Scott
169
+
170
+ * Update README.md (#20)
171
+ Nicolas
172
+
173
+ * Remove jruby 1.9 mode from the build matrix
174
+ Tom Scott
175
+
176
+ * Remove test because why
177
+ Tom Scott
178
+
179
+ v2.0.0
180
+ --------------------------------------------------------------------------------
181
+
182
+ * v2.0: Drop support for Ruby below 2.2 (thanks @connorshea)
183
+
184
+ Fixes #17, major shoutouts to @connorshea for getting this off the
185
+ ground. This also edits the CI config to drop support for older Ruby
186
+ versions.
187
+ Tom Scott
188
+
189
+ * Fix gem dependency versions
190
+ Tom Scott
191
+
192
+ * v2.0.0.pre Add support for Rails 5 and Rack 2.
193
+ Tom Scott
194
+
195
+ * v2.0.0: Upgrade to Rack 2.0
196
+
197
+ This release includes some backwards-incompatible changes that pertain
198
+ to Rails' upgrade to Rack 2.x.
199
+ Tom Scott
200
+
201
+ * Update README
202
+ Tom Scott
203
+
204
+ * Fix readme
205
+ Tom Scott
206
+
207
+ * travis.yml add Ruby 2.3.0
208
+ shiro16
209
+
210
+ * add 2.1 and 2.2 rubies to travis
211
+ Marc Roberts
212
+
213
+ * Remove support for Ruby 1.9
214
+ Marc Roberts
215
+
216
+ * Loosen dependancy on Rack to allow 1.5 and 2.x
217
+
218
+ Rails 5 beta requires Rack 2.x and this gem is unusable unless can use Rack 2.x
219
+ Marc Roberts
220
+
221
+ * Update README.md
222
+ Ryan Bigg
223
+
224
+ * add support for ConnectionPool
225
+ Roman Usherenko
226
+
227
+ * Introduce redis_store option (closes #1)
228
+ Kurakin Alexander
229
+
230
+ * Atomically lock session id and implement skip support.
231
+ W. Andrew Loe III
232
+
233
+ v1.5.0
234
+ ------
235
+
236
+ * Enable CI
237
+ Luca Guidi
238
+
239
+ * Update README.md
240
+ Luca Guidi
241
+
242
+ * Moved back from jodosha/redis-store
243
+ Luca Guidi
244
+
245
+ * Moved
246
+ Luca Guidi
data/Gemfile CHANGED
@@ -1,2 +1,6 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+
5
+ gem 'redis-store-testing', github: 'redis-store/testing'
6
+ gem 'appraisal', '~> 2.2'
@@ -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.to_hash)].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.to_hash) }
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
@@ -62,7 +65,7 @@ module Rack
62
65
  @default_options.fetch(:threadsafe, true)
63
66
  end
64
67
 
65
- def with_lock(req, default=nil)
68
+ def with_lock(req, default = nil)
66
69
  @mutex.lock if req.multithread? && threadsafe?
67
70
  yield
68
71
  rescue Errno::ECONNREFUSED
@@ -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,8 @@
1
1
  class Redis
2
2
  module Rack
3
3
  class Connection
4
+ POOL_KEYS = %i[pool pool_size pool_timeout].freeze
5
+
4
6
  def initialize(options = {})
5
7
  @options = options
6
8
  @store = options[:redis_store]
@@ -24,7 +26,9 @@ class Redis
24
26
  end
25
27
 
26
28
  def pooled?
27
- [:pool, :pool_size, :pool_timeout].any? { |key| @options.key?(key) }
29
+ return @pooled if defined?(@pooled)
30
+
31
+ @pooled = POOL_KEYS.any? { |key| @options.key?(key) }
28
32
  end
29
33
 
30
34
  def pool
@@ -1,6 +1,5 @@
1
1
  class Redis
2
2
  module Rack
3
- VERSION = '2.1.0.pre'
3
+ VERSION = '2.1.4'
4
4
  end
5
5
  end
6
-
data/redis-rack.gemspec CHANGED
@@ -12,22 +12,18 @@ 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
- s.add_development_dependency 'rake', '~> 10'
23
+ s.add_development_dependency 'rake', '>= 12.3.3'
26
24
  s.add_development_dependency 'bundler', '> 1', '< 3'
27
25
  s.add_development_dependency 'mocha', '~> 0.14.0'
28
26
  s.add_development_dependency 'minitest', '~> 5'
29
- s.add_development_dependency 'redis-store-testing'
30
27
  s.add_development_dependency 'connection_pool', '~> 1.2.0'
31
- s.add_development_dependency 'appraisal'
32
28
  end
33
29
 
@@ -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,42 +1,42 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-store
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
17
  - - "<"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '1.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.2'
30
27
  - - "<"
31
28
  - !ruby/object:Gem::Version
32
29
  version: '2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rack
35
35
  requirement: !ruby/object:Gem::Requirement
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'
@@ -54,16 +54,16 @@ dependencies:
54
54
  name: rake
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '10'
59
+ version: 12.3.3
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: '10'
66
+ version: 12.3.3
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -112,20 +112,6 @@ dependencies:
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
114
  version: '5'
115
- - !ruby/object:Gem::Dependency
116
- name: redis-store-testing
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
115
  - !ruby/object:Gem::Dependency
130
116
  name: connection_pool
131
117
  requirement: !ruby/object:Gem::Requirement
@@ -140,20 +126,6 @@ dependencies:
140
126
  - - "~>"
141
127
  - !ruby/object:Gem::Version
142
128
  version: 1.2.0
143
- - !ruby/object:Gem::Dependency
144
- name: appraisal
145
- requirement: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- version: '0'
157
129
  description: Redis Store for Rack applications
158
130
  email:
159
131
  - me@lucaguidi.com
@@ -165,6 +137,7 @@ files:
165
137
  - ".gitignore"
166
138
  - ".ruby-version"
167
139
  - ".travis.yml"
140
+ - CHANGELOG.md
168
141
  - CODEOWNERS
169
142
  - Gemfile
170
143
  - MIT-LICENSE
@@ -184,7 +157,7 @@ homepage: http://redis-store.org/redis-rack
184
157
  licenses:
185
158
  - MIT
186
159
  metadata: {}
187
- post_install_message:
160
+ post_install_message:
188
161
  rdoc_options: []
189
162
  require_paths:
190
163
  - lib
@@ -195,12 +168,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
168
  version: '0'
196
169
  required_rubygems_version: !ruby/object:Gem::Requirement
197
170
  requirements:
198
- - - ">"
171
+ - - ">="
199
172
  - !ruby/object:Gem::Version
200
- version: 1.3.1
173
+ version: '0'
201
174
  requirements: []
202
- rubygems_version: 3.0.3
203
- signing_key:
175
+ rubygems_version: 3.1.2
176
+ signing_key:
204
177
  specification_version: 4
205
178
  summary: Redis Store for Rack
206
179
  test_files: