redis-actionpack 5.0.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/lib/action_dispatch/middleware/session/redis_store.rb +5 -2
- data/lib/redis/actionpack/version.rb +1 -1
- data/redis-actionpack.gemspec +1 -1
- data/test/dummy/app/controllers/test_controller.rb +2 -2
- data/test/integration/redis_store_integration_test.rb +59 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c307087a763d1e0b3954ec756cd840ed1df3e8b
|
4
|
+
data.tar.gz: ee7c5f3361f0cf5c7e6009b033c6cb0524dbb0a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144bec146061a9b5e90b56e3e2a9224bb293766e6393a1d2510e06ae22e1cfa90f45ee3bc2330375a8b6282b05a9bfb22be23bdba943aa12bb33ec59986835f0
|
7
|
+
data.tar.gz: 642076a0bd7256abea58eb90cdcf8e0aac49c746614745f449a97539876a2bc2eeea1ce25703aa1069ec7c326400ef016d268980ea664950457b4e4a018cb643
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ gem 'redis-actionpack'
|
|
14
14
|
If you are using redis-store with Rails, consider using the [redis-rails gem](https://github.com/redis-store/redis-rails) instead. For standalone usage:
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
ActionController::Base.cache_store = ActionDispatch::Session::
|
17
|
+
ActionController::Base.cache_store = ActionDispatch::Session::RedisStore.new
|
18
18
|
```
|
19
19
|
|
20
20
|
## Running tests
|
@@ -18,13 +18,16 @@ module ActionDispatch
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def set_cookie(env, session_id, cookie)
|
21
|
-
|
22
21
|
if env.is_a? ActionDispatch::Request
|
23
22
|
request = env
|
24
23
|
else
|
25
24
|
request = ActionDispatch::Request.new(env)
|
26
25
|
end
|
27
|
-
request.cookie_jar[key] = cookie
|
26
|
+
request.cookie_jar[key] = cookie.merge(cookie_options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def cookie_options
|
30
|
+
@default_options.slice(:httponly, :secure)
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
data/redis-actionpack.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
|
-
s.add_runtime_dependency 'redis-store', '>= 1.1.0', '<
|
22
|
+
s.add_runtime_dependency 'redis-store', '>= 1.1.0', '< 2'
|
23
23
|
s.add_runtime_dependency 'redis-rack', '>= 1', '< 3'
|
24
24
|
s.add_runtime_dependency 'actionpack', '>= 4.0', '< 6'
|
25
25
|
|
@@ -19,12 +19,12 @@ class TestController < ActionController::Base
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def get_session_value
|
22
|
-
render :
|
22
|
+
render plain: "foo: #{session[:foo].inspect}"
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_session_id
|
26
26
|
session_id = request.session_options[:id] || cookies["_session_id"]
|
27
|
-
render :
|
27
|
+
render plain: session_id
|
28
28
|
end
|
29
29
|
|
30
30
|
def call_reset_session
|
@@ -43,6 +43,56 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
test "should set a non-secure cookie by default" do
|
47
|
+
with_test_route_set do
|
48
|
+
https!
|
49
|
+
|
50
|
+
get '/set_session_value'
|
51
|
+
assert_response :success
|
52
|
+
|
53
|
+
cookie = cookies.instance_variable_get('@cookies').first
|
54
|
+
|
55
|
+
assert !cookie.secure?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
test "should set a secure cookie when the 'secure' option is set" do
|
60
|
+
with_test_route_set(secure: true) do
|
61
|
+
https!
|
62
|
+
|
63
|
+
get '/set_session_value'
|
64
|
+
assert_response :success
|
65
|
+
|
66
|
+
cookie = cookies.instance_variable_get('@cookies').first
|
67
|
+
|
68
|
+
assert cookie.secure?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
test "should set a http-only cookie by default" do
|
73
|
+
with_test_route_set do
|
74
|
+
get '/set_session_value'
|
75
|
+
assert_response :success
|
76
|
+
|
77
|
+
cookie = cookies.instance_variable_get('@cookies').first
|
78
|
+
options = cookie.instance_variable_get('@options')
|
79
|
+
|
80
|
+
assert options.key?('HttpOnly')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
test "should set a non-http-only cookie when the 'httponlty' option is set to false" do
|
85
|
+
with_test_route_set(httponly: false) do
|
86
|
+
get '/set_session_value'
|
87
|
+
assert_response :success
|
88
|
+
|
89
|
+
cookie = cookies.instance_variable_get('@cookies').first
|
90
|
+
options = cookie.instance_variable_get('@options')
|
91
|
+
|
92
|
+
assert !options.key?('HttpOnly')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
46
96
|
test "should not send cookies on write, not read" do
|
47
97
|
with_test_route_set do
|
48
98
|
get '/get_session_value'
|
@@ -128,7 +178,7 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
|
|
128
178
|
|
129
179
|
reset!
|
130
180
|
|
131
|
-
get '/set_session_value', :_session_id
|
181
|
+
get '/set_session_value', headers: { _session_id: session_id }
|
132
182
|
assert_response :success
|
133
183
|
assert(cookies['_session_id'] != session_id)
|
134
184
|
end
|
@@ -199,7 +249,7 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
|
|
199
249
|
RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
|
200
250
|
middleware.use ActionDispatch::DebugExceptions
|
201
251
|
middleware.use ActionDispatch::Callbacks
|
202
|
-
middleware.use ActionDispatch::ParamsParser
|
252
|
+
# middleware.use ActionDispatch::ParamsParser
|
203
253
|
middleware.use ActionDispatch::Cookies
|
204
254
|
middleware.use ActionDispatch::Flash
|
205
255
|
middleware.use Rack::Head
|
@@ -211,7 +261,13 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
|
|
211
261
|
def with_test_route_set(options = {})
|
212
262
|
with_routing do |set|
|
213
263
|
set.draw do
|
214
|
-
get
|
264
|
+
get :no_session_access, to: 'test#no_session_access'
|
265
|
+
get :set_session_value, to: 'test#set_session_value'
|
266
|
+
get :set_session_value_with_expiry, to: 'test#set_session_value_with_expiry'
|
267
|
+
get :set_serialized_session_value, to: 'test#set_serialized_session_value'
|
268
|
+
get :get_session_value, to: 'test#get_session_value'
|
269
|
+
get :get_session_id, to: 'test#get_session_id'
|
270
|
+
get :call_reset_session, to: 'test#call_reset_session'
|
215
271
|
end
|
216
272
|
options = { :key => SessionKey }.merge!(options)
|
217
273
|
@app = self.class.build_app(set) do |middleware|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-store
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.1.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: '2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.1.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: '2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: redis-rack
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project: redis-actionpack
|
210
|
-
rubygems_version: 2.6.
|
210
|
+
rubygems_version: 2.6.11
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Redis session store for ActionPack
|