dalli 5.2.9 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,7 +46,10 @@ module Rack
46
46
  #
47
47
  # It is not recommended to set `:expires_in`. Instead, use `:expire_after`,
48
48
  # which will control both the expiration of the client cookie as well
49
- # as the expiration of the corresponding entry in memcached.
49
+ # as the expiration of the corresponding entry in memcached. Without
50
+ # `:expire_after`, sessions are stored with no expiry: one stays in
51
+ # memcached until it's deleted (for example by a logout) or memcached
52
+ # evicts it, and a stolen session cookie keeps working until then.
50
53
  #
51
54
  # Rack::Session::Dalli also accepts a host of options that control how
52
55
  # the sessions and session cookies are managed, including the
@@ -144,6 +147,11 @@ module Rack
144
147
  sid.private_id if sid.respond_to?(:private_id)
145
148
  end
146
149
 
150
+ # A session that can't be decoded, for example after a change of
151
+ # serializer or a deploy that removed a class stored in it, is treated
152
+ # as missing, so the request gets a new session. Otherwise the session
153
+ # id couldn't be used or replaced, and the user couldn't log in until
154
+ # the cookie was cleared.
147
155
  def existing_session_for_sid(client, sid)
148
156
  return nil unless sid && !sid.empty?
149
157
 
@@ -151,6 +159,9 @@ module Rack
151
159
  return nil if key.nil?
152
160
 
153
161
  client.get(key)
162
+ rescue ::Dalli::UnmarshalError => e
163
+ ::Dalli.logger.warn("#{self.class} couldn't decode a stored session, so it started a new one: #{e.message}")
164
+ nil
154
165
  end
155
166
 
156
167
  def create_sid_with_empty_session(client)
@@ -184,12 +195,9 @@ module Rack
184
195
  end
185
196
  end
186
197
 
187
- # Rails stores an ActionDispatch::Request::Session::Options in the env, not a
188
- # Hash. It implements [] (and to_hash) but not Hash#slice, so slicing it
189
- # raised NoMethodError instead of returning this 401.
190
198
  def missing_session_response(env)
191
199
  options = env[Rack::RACK_SESSION_OPTIONS] || @default_options
192
- cookie = Rack::Utils.delete_set_cookie_header(key, { path: options[:path], domain: options[:domain] })
200
+ cookie = Rack::Utils.delete_set_cookie_header(key, options.slice(:path, :domain))
193
201
  [401, { 'content-type' => 'text/plain', 'set-cookie' => cookie }, ['Wrong session ID']]
194
202
  end
195
203
 
@@ -234,8 +242,6 @@ module Rack
234
242
  def with_dalli_client(result_on_error = nil, &)
235
243
  @data.with(&)
236
244
  rescue ::Dalli::DalliError, Errno::ECONNREFUSED
237
- raise if $ERROR_INFO.message.include?('undefined class')
238
-
239
245
  if $VERBOSE
240
246
  warn "#{self} is unable to find memcached server."
241
247
  warn $ERROR_INFO.inspect
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.9
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter M. Goldstein
@@ -44,6 +44,7 @@ files:
44
44
  - lib/dalli/flags.rb
45
45
  - lib/dalli/instrumentation.rb
46
46
  - lib/dalli/json_serializer.rb
47
+ - lib/dalli/key_grouping.rb
47
48
  - lib/dalli/key_manager.rb
48
49
  - lib/dalli/options.rb
49
50
  - lib/dalli/pipelined_deleter.rb
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  requirements: []
92
- rubygems_version: 4.0.24
93
+ rubygems_version: 4.0.23
93
94
  specification_version: 4
94
95
  summary: High performance memcached client for Ruby
95
96
  test_files: []