rack-session 0.1.0 → 0.2.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: ca669bfeeda8e9b9d563ae88f899301acc7d8df1bfebb6768762edc9e99fb895
4
- data.tar.gz: 16170181b6d0eb480807ccff0cbd04ad4d8208a33251317ecdd1da202ed1076c
3
+ metadata.gz: bb2330b8031f50a3d80ca25857aac9db3636ed03d90aad824c8a191ec74cb4a3
4
+ data.tar.gz: 40323d8725c0a23f017d2017c29ee3abfa2fb811b13d12492d62e28e2a6b8274
5
5
  SHA512:
6
- metadata.gz: fc97739262aca4442a56ff5ad029adeb20f461637fd8730f819f0c8c5faa0e0aef736d64366031312393e04cfce44ec9b44c5a6bb4548b75be85c2c89a8f6d3d
7
- data.tar.gz: dbcbf050c12610a82a37a02fa1f2e75b46cb5d2d0644b6a1e55175a76feca1afe7780746f04dd91575d54665ff2d0983eb262c37ed6291eac8a214b2e8071db3
6
+ metadata.gz: 227c65c2acd9f8f05d76a424200e2c151006fb37ef271fde09f4ac73abb5ef8fc91dd9accf75cc901e9d09bc1347a38990dbe590d8f017fa59a4cb67e1b70536
7
+ data.tar.gz: dc24af294baf201629cc0ddd362cbe614acda5408acdb48be12e00b1ba8d567ee69a6f2d831cbc35a3e7b389f06a44e2b2c65234143686e5ab4f5ce6dbe7eb94
@@ -11,6 +11,8 @@ require 'rack/constants'
11
11
  require 'rack/request'
12
12
  require 'rack/response'
13
13
 
14
+ require_relative '../constants'
15
+
14
16
  module Rack
15
17
 
16
18
  module Session
@@ -415,10 +417,9 @@ module Rack
415
417
  # Sets the cookie back to the client with session id. We skip the cookie
416
418
  # setting if the value didn't change (sid is the same) or expires was given.
417
419
 
418
- def set_cookie(request, res, cookie)
420
+ def set_cookie(request, response, cookie)
419
421
  if request.cookies[@key] != cookie[:value] || cookie[:expires]
420
- res.set_cookie_header =
421
- Utils.add_cookie_to_header(res.set_cookie_header, @key, cookie)
422
+ response.set_cookie(@key, cookie)
422
423
  end
423
424
  end
424
425
 
@@ -1,6 +1,7 @@
1
-
2
1
  module Rack
3
2
  module Session
3
+ RACK_SESSION = 'rack.session'
4
+ RACK_SESSION_OPTIONS = 'rack.session.options'
4
5
  RACK_SESSION_UNPACKED_COOKIE_DATA = 'rack.session.unpacked_cookie_data'
5
6
  end
6
7
  end
@@ -11,6 +11,7 @@ require 'rack/utils'
11
11
 
12
12
  require_relative 'abstract/id'
13
13
  require_relative 'encryptor'
14
+ require_relative 'constants'
14
15
 
15
16
  module Rack
16
17
 
@@ -151,7 +152,8 @@ module Rack
151
152
  attr_reader :coder, :encryptors
152
153
 
153
154
  def initialize(app, options = {})
154
- secrets = [*options[:secrets]]
155
+ # support both :secrets and :secret for backwards compatibility
156
+ secrets = [*(options[:secrets] || options[:secret])]
155
157
 
156
158
  encryptor_opts = {
157
159
  purpose: options[:key], serialize_json: options[:serialize_json]
@@ -163,11 +165,12 @@ module Rack
163
165
  Rack::Session::Encryptor.new secret, encryptor_opts
164
166
  end
165
167
 
166
- # If a legacy HMAC secret is present, initialize those features
167
- if options.has_key?(:legacy_hmac_secret)
168
+ # If a legacy HMAC secret is present, initialize those features.
169
+ # Fallback to :secret for backwards compatibility.
170
+ if options.has_key?(:legacy_hmac_secret) || options.has_key?(:secret)
168
171
  @legacy_hmac = options.fetch(:legacy_hmac, 'SHA1')
169
172
 
170
- @legacy_hmac_secret = options[:legacy_hmac_secret]
173
+ @legacy_hmac_secret = options[:legacy_hmac_secret] || options[:secret]
171
174
  @legacy_hmac_coder = options.fetch(:legacy_hmac_coder, Base64::Marshal.new)
172
175
  else
173
176
  @legacy_hmac = false
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Rack
15
15
  module Session
16
- VERSION = "0.1.0"
16
+ VERSION = "0.2.0"
17
17
  end
18
18
  end
data/lib/rack/session.rb CHANGED
@@ -1,6 +1,7 @@
1
-
2
1
  module Rack
3
- RACK_SESSION = 'rack.session'
4
- RACK_SESSION_OPTIONS = 'rack.session.options'
5
- RACK_SESSION_UNPACKED_COOKIE_DATA = 'rack.session.unpacked_cookie_data'
2
+ module Session
3
+ autoload :Cookie, "rack/session/cookie"
4
+ autoload :Pool, "rack/session/pool"
5
+ autoload :Memcache, "rack/session/memcache"
6
+ end
6
7
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-session
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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-02-17 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitest
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -91,7 +105,6 @@ files:
91
105
  - lib/rack/session/constants.rb
92
106
  - lib/rack/session/cookie.rb
93
107
  - lib/rack/session/encryptor.rb
94
- - lib/rack/session/memcache.rb
95
108
  - lib/rack/session/pool.rb
96
109
  - lib/rack/session/version.rb
97
110
  homepage: https://github.com/rack/rack-session
@@ -113,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
126
  - !ruby/object:Gem::Version
114
127
  version: '0'
115
128
  requirements: []
116
- rubygems_version: 3.4.0.dev
129
+ rubygems_version: 3.3.7
117
130
  signing_key:
118
131
  specification_version: 4
119
132
  summary: A session implementation for Rack.
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rack/session/dalli'
4
-
5
- module Rack
6
- module Session
7
- warn "Rack::Session::Memcache is deprecated, please use Rack::Session::Dalli from 'dalli' gem instead."
8
- Memcache = Dalli
9
- end
10
- end