slab-redis-actionpack 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 942198c8a0f3bd43554e88ff61630b0bd721152226b45a0584060563fa69e4b3
4
+ data.tar.gz: 511fe8224526b8d10c37038d95615aa18f3ba2c8546e2cf6286683fb775ca31b
5
+ SHA512:
6
+ metadata.gz: a4f8380a08044197cd8b79bb458f4492d4ecbb94302d42ed6ce4e15e88fa1dae0c301301248aa0f591dddd53727795c3dd72d624971269a7dfdaec14873bb08c
7
+ data.tar.gz: 917496a9df49b61232b0992571ebf54b8b231bf2174f7efdd4b4ee778abba83c075352a9dfb6c67993fc563db3542fa12c0aae5d82c0ce520cfa4b08dc163592
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'redis/actionpack/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'slab-redis-actionpack'
7
+ s.version = Redis::ActionPack::VERSION
8
+ s.authors = ['Shodai Suzuki']
9
+ s.email = ['shodaiconnection@gmail.com']
10
+ s.homepage = 'https://github.com/soartec-lab/redis-actionpack'
11
+ s.summary = %q{Redis session store for ActionPack. redis-actionpack Gem replacement}
12
+ s.description = "#{s.summary}. Used for storing the Rails session in Redis."
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = []
18
+ s.require_paths = ['lib']
19
+ s.required_ruby_version = '>= 2.3.0'
20
+
21
+ s.add_runtime_dependency 'redis-store', '>= 1.1.0', '< 2'
22
+ s.add_runtime_dependency 'redis-rack', '>= 2.1.0', '< 3'
23
+ s.add_runtime_dependency 'actionpack', '>= 5', '< 8'
24
+ end
@@ -0,0 +1,2 @@
1
+ assignees:
2
+ - tubbo
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ gemfiles/*.lock
3
+ *.gem
4
+ tmp/
5
+ stdout
6
+ gemfiles/vendor
data/.travis.yml ADDED
@@ -0,0 +1,33 @@
1
+ language: ruby
2
+ before_install: gem install bundler
3
+ script: bundle exec rake
4
+ rvm:
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+ - 2.7
10
+ - ruby-head
11
+ - jruby-head
12
+ gemfile:
13
+ - gemfiles/rails_5.0.x.gemfile
14
+ - gemfiles/rails_5.1.x.gemfile
15
+ - gemfiles/rails_5.2.x.gemfile
16
+ - gemfiles/rails_6.0.x.gemfile
17
+ matrix:
18
+ exclude:
19
+ - rvm: 2.3
20
+ gemfile: gemfiles/rails_6.0.x.gemfile
21
+ - rvm: 2.4
22
+ gemfile: gemfiles/rails_6.0.x.gemfile
23
+ allow_failures:
24
+ - rvm: ruby-head
25
+ - rvm: jruby-head
26
+ deploy:
27
+ provider: rubygems
28
+ api_key:
29
+ secure: edRiCZPzp3pqBQn3hjeG5WqUNf0eEb8/Ea2VY0jJfQfOHxOYJSATkpdZ5xxOL1YIefk7ERUURY3dKwS/qdSIF2h954QPeOChLTlSaWtFjSNAZIAhH7Ks4vN/q1i7JAWtJRCBOtHlAe9AJj7CvHpUsry3+oHsJ+gXaaA9lntbheE=
30
+ gem: redis-actionpack
31
+ on:
32
+ tags: true
33
+ repo: redis-store/redis-actionpack
data/Appraisals ADDED
@@ -0,0 +1,23 @@
1
+ appraise 'rails-5.0.x' do
2
+ gem 'redis-store'
3
+ gem 'redis-rack'
4
+ gem 'actionpack', '~> 5.0.0'
5
+ end
6
+
7
+ appraise 'rails-5.1.x' do
8
+ gem 'redis-store'
9
+ gem 'redis-rack'
10
+ gem 'actionpack', '~> 5.1.0'
11
+ end
12
+
13
+ appraise 'rails-5.2.x' do
14
+ gem 'redis-store'
15
+ gem 'redis-rack'
16
+ gem 'actionpack', '~> 5.1.0'
17
+ end
18
+
19
+ appraise 'rails-6.0.x' do
20
+ gem 'redis-store'
21
+ gem 'redis-rack'
22
+ gem 'actionpack', '~> 6.0.0'
23
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,252 @@
1
+ v5.2.0 (2020-01-13)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Require latest version of redis-rack
5
+ Tom Scott
6
+
7
+ * Update version to v5.2.0 final
8
+ Tom Scott
9
+
10
+ * Fix for rack 2.0.8 (#28)
11
+
12
+ * Fix for rack 2.0.8
13
+ * add new redis-rack for tests
14
+ * add new ruby 2.7 for tests
15
+ Alexey Vasiliev
16
+
17
+ * v5.2.0.pre: Support Signed/Encrypted Cookies
18
+ Tom Scott
19
+
20
+ * Update README with info about signed cookies
21
+ Tom Scott
22
+
23
+ * Support Signed and Encrypted Cookie Storage (#27)
24
+
25
+ With the `:signed` option passed into the Redis session store, you can
26
+ now ensure that sessions will be set up in the browser using a
27
+ signed/encrypted cookie. This prevents user tampering by changing their
28
+ session ID or the data within the cookie.
29
+
30
+ Closes #21
31
+ Tom Scott
32
+
33
+ v5.1.0
34
+ --------------------------------------------------------------------------------
35
+
36
+ * Add appraisal to test on multiple versions of Rails (#18)
37
+
38
+ Update the build configuration to exclude older versions we no longer support and use Appraisal to test against multiple gemfiles/rubies in CI.
39
+
40
+ * Remove old gemfiles
41
+ * Update appraisal gemfiles
42
+ * Exclude some builds
43
+ * Install bundler on older versions of Ruby
44
+ * Prevent updating bundler to a non-compatible version
45
+ * Remove lockfiles from the repo
46
+ * Drop support for old versions of Rails & Ruby
47
+ * Automatically assign issues to @tubbo when they are created
48
+ Tom Scott
49
+
50
+ * Reduce build scope to only support Rails 5 & 6
51
+ Tom Scott
52
+
53
+ * v5.1.0: Support Rails 6
54
+ Tom Scott
55
+
56
+ * Bump max version constraint on actionpack (#25)
57
+
58
+ This change allows this gem to work with Rails 6.
59
+ Arjun Radhakrishnan
60
+
61
+ * Fix build
62
+ Tom Scott
63
+
64
+ * README: Use SVG badges
65
+ Olle Jonsson
66
+
67
+ * Gemspec: Drop EOL'd property rubyforge_project
68
+ Olle Jonsson
69
+
70
+ * Loosen Bundler dependency
71
+ Tom Scott
72
+
73
+ * Update testing matrix
74
+ Tom Scott
75
+
76
+ * Automatically release to RubyGems when new tags are pushed to GitHub
77
+ Tom Scott
78
+
79
+ * Add code owners
80
+ Tom Scott
81
+
82
+ * Clarify usage of gem in the README
83
+ Tom Scott
84
+
85
+ * Fix rails 4 build failure
86
+ Tom Scott
87
+
88
+ * Don't always use local testing gem
89
+ Tom Scott
90
+
91
+ v5.0.2
92
+ --------------------------------------------------------------------------------
93
+
94
+ * v5.0.2: Loosen dependencies to work with new minor redis-store versions
95
+ Tom Scott
96
+
97
+ * Update class name in README
98
+ Tom Scott
99
+
100
+ * Loosen redis-store dependency
101
+ Tom Scott
102
+
103
+ * Update tests to remove deprecation warnings
104
+ Tom Scott
105
+
106
+ * Remove testing code from Gemfile
107
+ Tom Scott
108
+
109
+ v5.0.1
110
+ --------------------------------------------------------------------------------
111
+
112
+ * Release v5.0.1
113
+ Tom Scott
114
+
115
+ * Respect cookie options in setting cookie with session ID
116
+ Michael Dawson
117
+
118
+ * Update tests and gemfiles to work on all supported versions.
119
+
120
+ Do not depend on pre-release versions of gems.
121
+
122
+ Move tests to use minitest-rails to alleviate some of the dependency hell.
123
+
124
+ Remove version_test.rb because that's dumb.
125
+ Connor Shea
126
+
127
+ v5.0.0
128
+ --------------------------------------------------------------------------------
129
+
130
+ * Update README.md (#12)
131
+ Nicolas
132
+
133
+ * Bump to 5.0.0
134
+ Ryan Bigg
135
+
136
+ * Fix gem dependency versions
137
+ Tom Scott
138
+
139
+ * Pre-Release of v5.0.0
140
+ Tom Scott
141
+
142
+ * Disable rbx-19mode on Travis CI
143
+
144
+ This syntax is no longer supported by Travis, so we aren't getting
145
+ reliable builds and thus must disable its use, at least for now. We were
146
+ getting problems on the Rails 4.0 and 4.1 Gemfiles.
147
+
148
+ More information is available at
149
+ https://travis-ci.org/redis-store/redis-actionpack/builds/112702496
150
+ Tom Scott
151
+
152
+ * exclue jruby-19 from rails5
153
+ Marc Roberts
154
+
155
+ * bump ruby 2.2 version in travis, rails5 need at least 2.2.4
156
+ Marc Roberts
157
+
158
+ * env is already an ActionDispatch::Request in rails5
159
+ Marc Roberts
160
+
161
+ * specify version of minitest-spec-rails
162
+ Marc Roberts
163
+
164
+ * need all of rails in gemfile for rails5
165
+ Marc Roberts
166
+
167
+ * use redis-store from github until a new gem is cut
168
+ Marc Roberts
169
+
170
+ * prevent rails5 deprecation warnings
171
+ Marc Roberts
172
+
173
+ * don't use mini_backtrace for now, incompatible with rails5
174
+ Marc Roberts
175
+
176
+ * bump rails5 gem version up to beta3
177
+ Marc Roberts
178
+
179
+ * use redis-rack via github for rails 5.0
180
+ Marc Roberts
181
+
182
+ * use minitest-spec-rails for consistency
183
+ Marc Roberts
184
+
185
+ * Merge remote-tracking branch 'upstream/master'
186
+ Miles Matthias
187
+
188
+ * update mini_specunit to minitest-spec-rails
189
+ Marc Roberts
190
+
191
+ * ignore .lock files in gemfiles
192
+ Marc Roberts
193
+
194
+ * correct gemfiles names in travis excludes
195
+ Marc Roberts
196
+
197
+ * fix gemspec path in gemfiles
198
+ Marc Roberts
199
+
200
+ * add multiple gemfiles for rails 4.0, 4.1, 4.2 and 5
201
+ Marc Roberts
202
+
203
+ * remove 1.9, add 2.1/2.2 rubies to travis
204
+ Marc Roberts
205
+
206
+ * Loosen dependancy on actionpack to support Rails 5
207
+ Marc Roberts
208
+
209
+ * travis ci add before_install
210
+ shiro16
211
+
212
+ * fixed travis.yml
213
+ shiro16
214
+
215
+ * travis ci add Ruby 2.1 and 2.2, 2.3.0
216
+ shiro16
217
+
218
+ * ignore stdout, file resulted from running tests
219
+ Miles Matthias
220
+
221
+ * Revert "Update README.md"
222
+
223
+ This reverts commit a4c7f94ed6283b28a34079b5a4917897d6a2b77d.
224
+ Ryan Bigg
225
+
226
+ * Update README.md
227
+ Ryan Bigg
228
+
229
+ * These silly version tests
230
+ Ryan Bigg
231
+
232
+ v4.0.1
233
+ --------------------------------------------------------------------------------
234
+ G
235
+ * Bump to 4.0.1
236
+ Ryan Bigg
237
+
238
+ * support the same values for domain as rails' session stores usually do
239
+
240
+ * needed to change the tests based on test in rails, so the options for the session store could be changed per test
241
+
242
+ Fixes #2
243
+ Michael Reinsch
244
+
245
+ v4.0.0
246
+ --------------------------------------------------------------------------------
247
+
248
+ * Enable CI
249
+ Luca Guidi
250
+
251
+ * Move from jodosha/redis-store
252
+ Luca Guidi
data/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @tubbo
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rake', '>= 12.3.3'
5
+ gem 'bundler', '~> 2.1'
6
+ gem 'mocha', '~> 0.14.0', require: 'mocha/setup'
7
+ gem 'tzinfo', '~> 1.2'
8
+ gem 'appraisal', '~> 2.2'
9
+ gem 'redis-store-testing', github: 'redis-store/testing'
10
+ gem 'minitest-rails'
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 - 2011 Luca Guidi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Redis stores for ActionPack
2
+
3
+ __`redis-actionpack`__ provides a session store for __ActionPack__, specifically for __ActionDispatch__. See the main [redis-store readme](https://github.com/redis-store/redis-store) for general guidelines.
4
+
5
+ For guidelines on using our underlying cache store, see the main [redis-store readme](https://github.com/redis-store/redis-store).
6
+
7
+ For information on how to use this library in a Rails app, see the [documentation for redis-rails](https://github.com/redis-store/redis-rails).
8
+
9
+ If, for some reason, you're using `ActionDispatch` and not in a Rails app, read on to learn how to install/use this gem by itself!
10
+
11
+ ## `redis-action pack` replacement gem
12
+
13
+ The original repository for this gem is https://github.com/redis-store/redis-actionpack.
14
+ I wanted to upgrade my application to Rails 7, so I sent a pull request to the original repository. The commits have been merged, but no new version containing the commit has been released to RubyGems. So I decided to fork and start development to support Rails 7.
15
+
16
+
17
+ ## Installation
18
+
19
+ ```ruby
20
+ # Gemfile
21
+ gem 'slab-redis-actionpack', require: 'redis-actionpack'
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ If you are using redis-store with Rails, head on over to the
27
+ [redis-rails README](https://github.com/redis-store/redis-rails#session-storage) to
28
+ learn how to integrate this gem into your Rails application.
29
+
30
+ For standalone usage:
31
+
32
+ ```ruby
33
+ ActionController::Base.session_store = :redis_store,
34
+ servers: %w(redis://localhost:6379/0/session),
35
+ expire_after: 90.minutes,
36
+ key: '_my_application_session',
37
+ threadsafe: false,
38
+ secure: true
39
+ ```
40
+
41
+ A brief run-down of these options...
42
+
43
+ - **servers** is an Array of Redis server URLs that we will attempt to find
44
+ data from.
45
+ - **expire_after** is the default TTL of session keys. This is also set
46
+ as the expiry time of any cookies generated by the session store.
47
+ - **key** is the name of the cookie on the client side
48
+ - **threadsafe** is for applications that run on multiple instances. Set
49
+ this to `false` if you want to disable the global mutex lock on
50
+ session data. It's `true` by default, meaning the mutex will be
51
+ enabled.
52
+ - **secure** ensures HTTP cookies are transferred from server to client
53
+ on a secure (HTTPS) connection
54
+
55
+ ## Running tests
56
+
57
+ ```shell
58
+ gem install bundler
59
+ git clone git://github.com/redis-store/redis-actionpack.git
60
+ cd redis-actionpack
61
+ bundle install
62
+ bundle exec rake
63
+ ```
64
+
65
+ If you are on **Snow Leopard** you have to run `env ARCHFLAGS="-arch x86_64" bundle exec rake`
66
+
67
+ ## Status
68
+
69
+ [![Gem Version](https://badge.fury.io/rb/redis-actionpack.svg)](http://badge.fury.io/rb/redis-actionpack)
70
+ [![Build Status](https://secure.travis-ci.org/redis-store/redis-actionpack.svg?branch=master)](http://travis-ci.org/redis-store/redis-actionpack?branch=master)
71
+ [![Code Climate](https://codeclimate.com/github/redis-store/redis-actionpack.svg)](https://codeclimate.com/github/redis-store/redis-actionpack)
72
+
73
+ ## Copyright
74
+
75
+ 2009 - 2013 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+ require 'rake'
3
+ require 'bundler/gem_tasks'
4
+ require 'redis-store/testing/tasks'
@@ -0,0 +1 @@
1
+ puts '-v 1.13.1' if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('2.3.0')
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", ">= 12.3.3"
6
+ gem "bundler", "~> 2.1"
7
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
+ gem "tzinfo", "~> 1.2"
9
+ gem "appraisal", "~> 2.2"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "minitest-rails"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 5.0.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", ">= 12.3.3"
6
+ gem "bundler", "~> 2.1"
7
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
+ gem "tzinfo", "~> 1.2"
9
+ gem "appraisal", "~> 2.2"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "minitest-rails"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 5.1.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", ">= 12.3.3"
6
+ gem "bundler", "~> 2.1"
7
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
+ gem "tzinfo", "~> 1.2"
9
+ gem "appraisal", "~> 2.2"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "minitest-rails"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 5.1.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", ">= 12.3.3"
6
+ gem "bundler", "~> 2.1"
7
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
+ gem "tzinfo", "~> 1.2"
9
+ gem "appraisal", "~> 2.2"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "minitest-rails"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 6.0.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'redis-store'
4
+ require 'redis-rack'
5
+ require 'action_dispatch/middleware/session/abstract_store'
6
+
7
+ module ActionDispatch
8
+ module Session
9
+ # Session storage in Redis, using +Redis::Rack+ as a basis.
10
+ class RedisStore < Rack::Session::Redis
11
+ include Compatibility
12
+ include StaleSessionCheck
13
+ include SessionObject
14
+
15
+ def initialize(app, options = {})
16
+ options = options.dup
17
+ options[:redis_server] ||= options[:servers]
18
+ super
19
+ end
20
+
21
+ def generate_sid
22
+ Rack::Session::SessionId.new(super)
23
+ end
24
+
25
+ private
26
+
27
+ def set_cookie(env, _session_id, cookie)
28
+ request = wrap_in_request(env)
29
+ cookie_jar(request)[key] = cookie.merge(cookie_options)
30
+ end
31
+
32
+ def get_cookie(request)
33
+ cookie_jar(request)[key]
34
+ end
35
+
36
+ def wrap_in_request(env)
37
+ return env if env.is_a?(ActionDispatch::Request)
38
+ ActionDispatch::Request.new(env)
39
+ end
40
+
41
+ def cookie_options
42
+ @default_options.slice(:httponly, :secure)
43
+ end
44
+
45
+ def cookie_jar(request)
46
+ if @default_options[:signed]
47
+ request.cookie_jar.signed_or_encrypted
48
+ else
49
+ request.cookie_jar
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ class Redis
2
+ module ActionPack
3
+ VERSION = '5.3.0'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'redis-store'
2
+ require 'action_pack'
3
+ require 'redis/actionpack/version'
4
+ require 'action_dispatch/middleware/session/redis_store'
@@ -0,0 +1 @@
1
+ log/*
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,42 @@
1
+ class TestController < ActionController::Base
2
+ def self.actions
3
+ public_instance_methods - ActionController::Base.public_instance_methods
4
+ end
5
+
6
+ def no_session_access
7
+ head :ok
8
+ end
9
+
10
+ def set_session_value
11
+ session[:foo] = "bar"
12
+ head :ok
13
+ end
14
+
15
+ def set_session_value_with_expiry
16
+ request.session_options[:expire_after] = 1.second
17
+ set_session_value
18
+ end
19
+
20
+ def set_serialized_session_value
21
+ session[:foo] = SessionAutoloadTest::Foo.new
22
+ head :ok
23
+ end
24
+
25
+ def get_session_value
26
+ render plain: "foo: #{session[:foo].inspect}"
27
+ end
28
+
29
+ def get_session_id
30
+ session_id = request.session_options[:id] || cookies["_session_id"]
31
+ render plain: session_id
32
+ end
33
+
34
+ def call_reset_session
35
+ session[:bar]
36
+ reset_session
37
+ session[:bar] = "baz"
38
+ head :ok
39
+ end
40
+
41
+ def rescue_action(e) raise end
42
+ end
File without changes
@@ -0,0 +1 @@
1
+ <h1>hello world</h1>
@@ -0,0 +1,30 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+
5
+ Bundler.require
6
+
7
+ module Dummy
8
+ class Application < Rails::Application
9
+ # Disable class caching for session auto-load test
10
+ config.cache_classes = false
11
+
12
+ config.eager_load = false
13
+
14
+ # Show full error reports and disable caching
15
+ config.consider_all_requests_local = true
16
+ config.action_controller.perform_caching = false
17
+
18
+ # Raise exceptions instead of rendering exception templates
19
+ config.action_dispatch.show_exceptions = false
20
+
21
+ # Disable request forgery protection in test environment
22
+ config.action_controller.allow_forgery_protection = false
23
+
24
+ # Print deprecation notices to the stderr
25
+ config.active_support.deprecation = :stderr
26
+
27
+ config.secret_key_base = 'secret'
28
+ end
29
+ end
30
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,5 @@
1
+ Dummy::Application.routes.draw do
2
+ TestController.actions.each do |action|
3
+ get action, to: ['test', action].join('#')
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,10 @@
1
+ module SessionAutoloadTest
2
+ class Foo
3
+ def initialize(bar='baz')
4
+ @bar = bar
5
+ end
6
+ def inspect
7
+ "#<#{self.class} bar:#{@bar.inspect}>"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => './../..'
3
+
4
+ gem 'redis-store'
5
+
6
+ gem 'redis-rack', github: 'redis-store/redis-rack'
7
+
8
+ gem 'actionpack', '~> 6.0.0'
9
+
10
+ gem 'minitest-rails'
@@ -0,0 +1,302 @@
1
+ require 'test_helper'
2
+
3
+ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
4
+ SessionKey = '_session_id'
5
+ SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33'
6
+
7
+ test "reads the data" do
8
+ with_test_route_set do
9
+ get '/set_session_value'
10
+ assert_response :success
11
+ assert cookies['_session_id'].present?
12
+
13
+ get '/get_session_value'
14
+ assert_response :success
15
+ assert_equal response.body, 'foo: "bar"'
16
+ end
17
+ end
18
+
19
+ test "should get nil session value" do
20
+ with_test_route_set do
21
+ get '/get_session_value'
22
+ assert_response :success
23
+ assert_equal 'foo: nil', response.body
24
+ end
25
+ end
26
+
27
+ test "should delete the data after session reset" do
28
+ with_test_route_set do
29
+ get '/set_session_value'
30
+ assert_response :success
31
+ assert cookies['_session_id'].present?
32
+ session_cookie = cookies.send(:hash_for)['_session_id']
33
+
34
+ get '/call_reset_session'
35
+ assert_response :success
36
+ assert !headers['Set-Cookie'].blank?
37
+
38
+ cookies << session_cookie
39
+
40
+ get '/get_session_value'
41
+ assert_response :success
42
+ assert_equal 'foo: nil', response.body
43
+ end
44
+ end
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 signed cookie when the 'signed' option is set" do
73
+ with_test_route_set(signed: true) do
74
+ https!
75
+
76
+ get '/set_session_value'
77
+ assert_response :success
78
+
79
+ cookie = cookies.instance_variable_get('@cookies').first
80
+
81
+ assert_includes cookie.raw, '_session_id='
82
+ end
83
+ end
84
+
85
+
86
+ test "should set a http-only cookie by default" do
87
+ with_test_route_set do
88
+ get '/set_session_value'
89
+ assert_response :success
90
+
91
+ cookie = cookies.instance_variable_get('@cookies').first
92
+ options = cookie.instance_variable_get('@options')
93
+
94
+ assert options.key?('HttpOnly')
95
+ end
96
+ end
97
+
98
+ test "should set a non-http-only cookie when the 'httponlty' option is set to false" do
99
+ with_test_route_set(httponly: false) do
100
+ get '/set_session_value'
101
+ assert_response :success
102
+
103
+ cookie = cookies.instance_variable_get('@cookies').first
104
+ options = cookie.instance_variable_get('@options')
105
+
106
+ assert !options.key?('HttpOnly')
107
+ end
108
+ end
109
+
110
+ test "should not send cookies on write, not read" do
111
+ with_test_route_set do
112
+ get '/get_session_value'
113
+ assert_response :success
114
+ assert_equal 'foo: nil', response.body
115
+ assert cookies['_session_id'].nil?
116
+ end
117
+ end
118
+
119
+ test "should set session value after session reset" do
120
+ with_test_route_set do
121
+ get '/set_session_value'
122
+ assert_response :success
123
+ assert cookies['_session_id'].present?
124
+ session_id = cookies['_session_id']
125
+
126
+ get '/call_reset_session'
127
+ assert_response :success
128
+ assert !headers['Set-Cookie'].blank?
129
+
130
+ get '/get_session_value'
131
+ assert_response :success
132
+ assert_equal 'foo: nil', response.body
133
+
134
+ get '/get_session_id'
135
+ assert_response :success
136
+ assert(response.body != session_id)
137
+ end
138
+ end
139
+
140
+ test "should be able to read session id without accessing the session hash" do
141
+ with_test_route_set do
142
+ get '/set_session_value'
143
+ assert_response :success
144
+ assert cookies['_session_id'].present?
145
+ session_id = cookies['_session_id']
146
+
147
+ get '/get_session_id'
148
+ assert_response :success
149
+ assert_equal response.body, session_id
150
+ end
151
+ end
152
+
153
+ test "should auto-load unloaded class" do
154
+ with_test_route_set do
155
+ with_autoload_path "session_autoload_test" do
156
+ get '/set_serialized_session_value'
157
+ assert_response :success
158
+ assert cookies['_session_id'].present?
159
+ end
160
+
161
+ with_autoload_path "session_autoload_test" do
162
+ get '/get_session_id'
163
+ assert_response :success
164
+ end
165
+
166
+ with_autoload_path "session_autoload_test" do
167
+ get '/get_session_value'
168
+ assert_response :success
169
+ assert_equal response.body, 'foo: #<SessionAutoloadTest::Foo bar:"baz">'
170
+ end
171
+ end
172
+ end
173
+
174
+ test "should not resend the cookie again if session_id cookie is already exists" do
175
+ with_test_route_set do
176
+ get '/set_session_value'
177
+ assert_response :success
178
+ assert cookies['_session_id'].present?
179
+
180
+ get '/get_session_value'
181
+ assert_response :success
182
+ assert headers['Set-Cookie'].nil?
183
+ end
184
+ end
185
+
186
+ test "should prevent session fixation" do
187
+ with_test_route_set do
188
+ get '/get_session_value'
189
+ assert_response :success
190
+ assert_equal 'foo: nil', response.body
191
+ session_id = cookies['_session_id']
192
+
193
+ reset!
194
+
195
+ get '/set_session_value', headers: { _session_id: session_id }
196
+ assert_response :success
197
+ assert(cookies['_session_id'] != session_id)
198
+ end
199
+ end
200
+
201
+ test "should write the data with expiration time" do
202
+ with_test_route_set do
203
+ get '/set_session_value_with_expiry'
204
+ assert_response :success
205
+
206
+ get '/get_session_value'
207
+ assert_response :success
208
+ assert_equal response.body, 'foo: "bar"'
209
+
210
+ sleep 1
211
+
212
+ get '/get_session_value'
213
+ assert_response :success
214
+ assert_equal 'foo: nil', response.body
215
+ end
216
+ end
217
+
218
+ test "session store with explicit domain" do
219
+ with_test_route_set(:domain => "example.es") do
220
+ get '/set_session_value'
221
+ assert_match(/domain=example\.es/, headers['Set-Cookie'])
222
+ headers['Set-Cookie']
223
+ end
224
+ end
225
+
226
+ test "session store without domain" do
227
+ with_test_route_set do
228
+ get '/set_session_value'
229
+ assert_no_match(/domain\=/, headers['Set-Cookie'])
230
+ end
231
+ end
232
+
233
+ test "session store with nil domain" do
234
+ with_test_route_set(:domain => nil) do
235
+ get '/set_session_value'
236
+ assert_no_match(/domain\=/, headers['Set-Cookie'])
237
+ end
238
+ end
239
+
240
+ test "session store with all domains" do
241
+ with_test_route_set(:domain => :all) do
242
+ get '/set_session_value'
243
+ assert_match(/domain=\.example\.com/, headers['Set-Cookie'])
244
+ end
245
+ end
246
+
247
+ private
248
+
249
+ # from actionpack/test/abstract_unit.rb
250
+ class RoutedRackApp
251
+ attr_reader :routes
252
+ def initialize(routes, &blk)
253
+ @routes = routes
254
+ @stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes)
255
+ @secret = SecureRandom.hex
256
+ @key_generator = ActiveSupport::CachingKeyGenerator.new(
257
+ ActiveSupport::KeyGenerator.new(@secret, iterations: 2)
258
+ )
259
+ end
260
+ def call(env)
261
+ env[ActionDispatch::Cookies::GENERATOR_KEY] = @key_generator
262
+ env[ActionDispatch::Cookies::SIGNED_COOKIE_SALT] = SecureRandom.hex
263
+ if defined? ActionDispatch::Cookies::COOKIES_ROTATIONS
264
+ env[ActionDispatch::Cookies::COOKIES_ROTATIONS] = ActiveSupport::Messages::RotationConfiguration.new
265
+ end
266
+ @stack.call(env)
267
+ end
268
+ end
269
+
270
+ # from actionpack/test/abstract_unit.rb
271
+ def self.build_app(routes = nil)
272
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
273
+ middleware.use ActionDispatch::DebugExceptions
274
+ middleware.use ActionDispatch::Callbacks
275
+ # middleware.use ActionDispatch::ParamsParser
276
+ middleware.use ActionDispatch::Cookies
277
+ middleware.use ActionDispatch::Flash
278
+ middleware.use Rack::Head
279
+ yield(middleware) if block_given?
280
+ end
281
+ end
282
+
283
+ # from actionpack/test/dispatch/session/cookie_store_test.rb
284
+ def with_test_route_set(options = {})
285
+ with_routing do |set|
286
+ set.draw do
287
+ get :no_session_access, to: 'test#no_session_access'
288
+ get :set_session_value, to: 'test#set_session_value'
289
+ get :set_session_value_with_expiry, to: 'test#set_session_value_with_expiry'
290
+ get :set_serialized_session_value, to: 'test#set_serialized_session_value'
291
+ get :get_session_value, to: 'test#get_session_value'
292
+ get :get_session_id, to: 'test#get_session_id'
293
+ get :call_reset_session, to: 'test#call_reset_session'
294
+ end
295
+ options = { :key => SessionKey }.merge!(options)
296
+ @app = self.class.build_app(set) do |middleware|
297
+ middleware.use ActionDispatch::Session::RedisStore, options
298
+ end
299
+ yield
300
+ end
301
+ end
302
+ end
@@ -0,0 +1,24 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'active_support/core_ext/numeric/time'
4
+
5
+ ENV["RAILS_ENV"] = "test"
6
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
+ require "rails/test_help"
8
+
9
+ Rails.backtrace_cleaner.remove_silencers!
10
+
11
+ def with_autoload_path(path)
12
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
13
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
14
+ yield
15
+ else
16
+ begin
17
+ ActiveSupport::Dependencies.autoload_paths << path
18
+ yield
19
+ ensure
20
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
21
+ ActiveSupport::Dependencies.clear
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slab-redis-actionpack
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Shodai Suzuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redis-store
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: redis-rack
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.1.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.1.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3'
53
+ - !ruby/object:Gem::Dependency
54
+ name: actionpack
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '5'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '8'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '5'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '8'
73
+ description: Redis session store for ActionPack. redis-actionpack Gem replacement.
74
+ Used for storing the Rails session in Redis.
75
+ email:
76
+ - shodaiconnection@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - " slab-redis-actionpack.gemspec"
82
+ - ".github/auto-assign-issues.yml"
83
+ - ".gitignore"
84
+ - ".travis.yml"
85
+ - Appraisals
86
+ - CHANGELOG.md
87
+ - CODEOWNERS
88
+ - Gemfile
89
+ - MIT-LICENSE
90
+ - README.md
91
+ - Rakefile
92
+ - bin/bundler-version-options.rb
93
+ - gemfiles/rails_5.0.x.gemfile
94
+ - gemfiles/rails_5.1.x.gemfile
95
+ - gemfiles/rails_5.2.x.gemfile
96
+ - gemfiles/rails_6.0.x.gemfile
97
+ - lib/action_dispatch/middleware/session/redis_store.rb
98
+ - lib/redis-actionpack.rb
99
+ - lib/redis/actionpack/version.rb
100
+ - test/dummy/.gitignore
101
+ - test/dummy/Rakefile
102
+ - test/dummy/app/controllers/test_controller.rb
103
+ - test/dummy/app/views/test/get_session_id.html.erb
104
+ - test/dummy/app/views/test/get_session_value.html.erb
105
+ - test/dummy/config.ru
106
+ - test/dummy/config/application.rb
107
+ - test/dummy/config/boot.rb
108
+ - test/dummy/config/environment.rb
109
+ - test/dummy/config/routes.rb
110
+ - test/dummy/script/rails
111
+ - test/fixtures/session_autoload_test/session_autoload_test/foo.rb
112
+ - test/gemfiles/Gemfile.rails-6.0.x
113
+ - test/integration/redis_store_integration_test.rb
114
+ - test/test_helper.rb
115
+ homepage: https://github.com/soartec-lab/redis-actionpack
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: 2.3.0
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubygems_version: 3.2.32
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Redis session store for ActionPack. redis-actionpack Gem replacement
138
+ test_files:
139
+ - test/dummy/.gitignore
140
+ - test/dummy/Rakefile
141
+ - test/dummy/app/controllers/test_controller.rb
142
+ - test/dummy/app/views/test/get_session_id.html.erb
143
+ - test/dummy/app/views/test/get_session_value.html.erb
144
+ - test/dummy/config.ru
145
+ - test/dummy/config/application.rb
146
+ - test/dummy/config/boot.rb
147
+ - test/dummy/config/environment.rb
148
+ - test/dummy/config/routes.rb
149
+ - test/dummy/script/rails
150
+ - test/fixtures/session_autoload_test/session_autoload_test/foo.rb
151
+ - test/gemfiles/Gemfile.rails-6.0.x
152
+ - test/integration/redis_store_integration_test.rb
153
+ - test/test_helper.rb