mongo_session_store 3.2.2 → 3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d43ac777d775e4cb749414668819d70cf193f0e2ba5095671efecb49217d3988
4
- data.tar.gz: 2b7adfc073d06d392a28f8c9625ea53b1a80c083bdc23c59c2726fb57032984d
3
+ metadata.gz: 8e3d5855f45006aba783cdc7edb80d07a3721d985c40b156548e596a2e1a50bb
4
+ data.tar.gz: 01a005c71cd44b77044bbfea12df9121d03ccf8a6bf80bd8f7626a3153ed216d
5
5
  SHA512:
6
- metadata.gz: 3190b6a8071c1c141c5ce81f7e362ea6350790ff8338769bcc0730dbc12bc277d80b5be37c5cf4bd6680042353fb0fd483785feb200f37e9f6dcd6dec4478763
7
- data.tar.gz: 2d194275cc082008d673860b7c3b750e1224922e84ff0a641255959f5e290baedf904dfd619c0adb3b70c441ae9d3ce203e29d3dfabfd8d42a17767cd2e5380d
6
+ metadata.gz: 90ae3da4b0804b39df8710b2c69bf66a1a5330422cab88d091cf41e177713b038bcd8626342ef6dc7a26615bb0efddfe6f7e5f498bd694b33d1272bfa2c5b1ff
7
+ data.tar.gz: 8cfe12b69f98fb936e51404a9cf54b8d330ce805e174c0b020dcc606d9c2906a76eccb9e41fe2e1afe6f525599fb471e6c7c72a6216d72a499cddcee96e1b49e
@@ -12,23 +12,37 @@ on:
12
12
 
13
13
  concurrency:
14
14
  group: "${{ github.workflow }}-${{ github.ref }}"
15
- cancel-in-progress: "${{ !contains(github.ref, 'main')}}"
15
+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
16
+
17
+ permissions:
18
+ contents: read
16
19
 
17
20
  jobs:
18
21
  test:
19
- name: "Run tests"
20
- runs-on: ubuntu-latest
22
+ name: "Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }} / Rails ${{ matrix.rails || 'pinned' }}"
23
+ runs-on: ubuntu-22.04
24
+ timeout-minutes: 15
21
25
 
22
26
  strategy:
23
27
  fail-fast: false
24
28
  matrix:
25
- ruby:
29
+ ruby:
26
30
  - "3.4"
27
31
  - "3.3"
28
32
  gemfile:
29
33
  - gemfiles/rails-6.0-mongo.gemfile
30
34
  - gemfiles/rails-6.0-mongoid.gemfile
31
35
  include:
36
+ - { ruby: "3.1", rails: "~> 6.1.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongo.gemfile }
37
+ - { ruby: "3.1", rails: "~> 6.1.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongoid.gemfile }
38
+ - { ruby: "3.1", rails: "~> 7.0.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongo.gemfile }
39
+ - { ruby: "3.1", rails: "~> 7.0.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongoid.gemfile }
40
+ - { ruby: "3.2", rails: "~> 7.1.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongo.gemfile }
41
+ - { ruby: "3.2", rails: "~> 7.1.0", mongoid: "~> 8.0", mongodb: "6.0", gemfile: gemfiles/rails-current-mongoid.gemfile }
42
+ - { ruby: "3.3", rails: "~> 7.2.0", mongoid: "~> 9.0", mongodb: "7.0", gemfile: gemfiles/rails-current-mongo.gemfile }
43
+ - { ruby: "3.3", rails: "~> 7.2.0", mongoid: "~> 9.0", mongodb: "7.0", gemfile: gemfiles/rails-current-mongoid.gemfile }
44
+ - { ruby: "3.4", rails: "~> 8.0.0", mongoid: "~> 9.0", mongodb: "8.0", sqlite: "~> 2.1", gemfile: gemfiles/rails-current-mongo.gemfile }
45
+ - { ruby: "3.4", rails: "~> 8.0.0", mongoid: "~> 9.0", mongodb: "8.0", sqlite: "~> 2.1", gemfile: gemfiles/rails-current-mongoid.gemfile }
32
46
  - gemfile: gemfiles/rails-8.1-mongo.gemfile
33
47
  ruby: "3.4"
34
48
  mongodb: "8.0"
@@ -41,6 +55,7 @@ jobs:
41
55
  - gemfile: gemfiles/rails-8.1-mongoid.gemfile
42
56
  ruby: "4.0"
43
57
  mongodb: "8.0"
58
+ coverage: "true"
44
59
  - gemfile: gemfiles/rails-5.2-mongo.gemfile
45
60
  ruby: "2.7"
46
61
  - gemfile: gemfiles/rails-5.2-mongoid.gemfile
@@ -60,13 +75,17 @@ jobs:
60
75
  ports:
61
76
  - 27017:27017
62
77
  options: >-
63
- --health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
78
+ --health-cmd "bash -c 'echo > /dev/tcp/127.0.0.1/27017'"
64
79
  --health-interval 10s
65
80
  --health-timeout 5s
66
81
  --health-retries 10
67
82
 
68
83
  env:
69
84
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
85
+ COVERAGE: ${{ matrix.coverage }}
86
+ RAILS_VERSION: ${{ matrix.rails }}
87
+ MONGOID_VERSION: ${{ matrix.mongoid }}
88
+ SQLITE_VERSION: ${{ matrix.sqlite || '~> 1.4' }}
70
89
 
71
90
  steps:
72
91
  - name: Checkout project
@@ -81,9 +100,26 @@ jobs:
81
100
  - name: Run tests
82
101
  run: bundle exec rake test
83
102
 
103
+ - name: Cover Mongo adapter
104
+ if: ${{ matrix.coverage == 'true' }}
105
+ env:
106
+ BUNDLE_GEMFILE: gemfiles/rails-8.1-mongo.gemfile
107
+ run: |
108
+ bundle install --jobs 4 --retry 3
109
+ bundle exec rake test
110
+
111
+ - name: Report coverage
112
+ if: ${{ matrix.coverage == 'true' }}
113
+ uses: coverallsapp/github-action@v2
114
+ with:
115
+ github-token: ${{ secrets.GITHUB_TOKEN }}
116
+ file: coverage/.resultset.json
117
+ format: simplecov
118
+
84
119
  rubocop:
85
120
  name: "RuboCop"
86
121
  runs-on: ubuntu-latest
122
+ timeout-minutes: 10
87
123
 
88
124
  steps:
89
125
  - name: Checkout project
@@ -5,6 +5,12 @@ on:
5
5
  workflows: [Danger]
6
6
  types: [completed]
7
7
 
8
+ permissions:
9
+ contents: read
10
+ actions: read
11
+ issues: write
12
+ pull-requests: write
13
+
8
14
  jobs:
9
15
  comment:
10
16
  uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
@@ -4,16 +4,24 @@ on:
4
4
  pull_request:
5
5
  types: [opened, reopened, edited, synchronize]
6
6
 
7
+ permissions:
8
+ contents: read
9
+
10
+ concurrency:
11
+ group: danger-${{ github.event.pull_request.number }}
12
+ cancel-in-progress: true
13
+
7
14
  jobs:
8
15
  danger:
9
16
  runs-on: ubuntu-latest
17
+ timeout-minutes: 10
10
18
 
11
19
  env:
12
20
  BUNDLE_GEMFILE: Gemfile.danger
13
21
 
14
22
  steps:
15
23
  - name: Checkout repository
16
- uses: actions/checkout@v4
24
+ uses: actions/checkout@v7
17
25
  with:
18
26
  fetch-depth: 0
19
27
 
@@ -27,8 +35,8 @@ jobs:
27
35
  id: danger
28
36
  continue-on-error: true
29
37
  env:
30
- DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
31
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
38
+ DANGER_GITHUB_API_TOKEN: ${{ github.token }}
39
+ GITHUB_TOKEN: ${{ github.token }}
32
40
  DANGER_REPORT_PATH: ${{ runner.temp }}/danger-report.json
33
41
  run: bundle exec danger dry_run
34
42
 
data/.gitignore CHANGED
@@ -4,5 +4,7 @@ Gemfile.lock
4
4
  gemfiles/*.lock
5
5
  spec/support/apps/rails_*/tmp/
6
6
  spec/support/apps/rails_*/db/*.sqlite3
7
+ spec/support/apps/rails_*/db/*.sqlite3-*
8
+ spec/support/apps/rails_*/log/
7
9
  *.gem
8
10
  /tmp/
data/.rubocop.yml CHANGED
@@ -1,7 +1,16 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
- TargetRubyVersion: 2.0
4
+ TargetRubyVersion: 2.6
5
+ NewCops: enable
3
6
  Include:
4
- - "Gemfile"
7
+ - "**/*.rb"
8
+ - "**/*.gemspec"
9
+ - "**/*.gemfile"
10
+ - "**/Gemfile"
11
+ - "**/Gemfile.danger"
12
+ - "**/Rakefile"
13
+ - "**/Dangerfile"
5
14
  Exclude:
6
15
  - "gemfiles/vendor/**/*"
7
16
  - "perf/benchmark.rb"
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,195 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2026-10-17 03:50:12 UTC using RuboCop version 1.92.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 26
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
12
+ Bundler/OrderedGems:
13
+ Exclude:
14
+ - 'gemfiles/rails-5.0-mongo.gemfile'
15
+ - 'gemfiles/rails-5.0-mongoid.gemfile'
16
+ - 'gemfiles/rails-5.1-mongo.gemfile'
17
+ - 'gemfiles/rails-5.1-mongoid.gemfile'
18
+ - 'gemfiles/rails-5.2-mongo.gemfile'
19
+ - 'gemfiles/rails-5.2-mongoid.gemfile'
20
+ - 'gemfiles/rails-6.0-mongo.gemfile'
21
+ - 'gemfiles/rails-6.0-mongoid.gemfile'
22
+ - 'gemfiles/rails-8.1-mongo.gemfile'
23
+ - 'gemfiles/rails-8.1-mongoid.gemfile'
24
+ - 'gemfiles/rails-current-mongo.gemfile'
25
+
26
+ # Offense count: 1
27
+ # This cop supports safe autocorrection (--autocorrect).
28
+ Gemspec/DeprecatedAttributeAssignment:
29
+ Exclude:
30
+ - 'mongo_session_store.gemspec'
31
+
32
+ # Offense count: 3
33
+ # Configuration parameters: EnforcedStyle, AllowedGems.
34
+ # SupportedStyles: Gemfile, gems.rb, gemspec
35
+ Gemspec/DevelopmentDependencies:
36
+ Exclude:
37
+ - 'mongo_session_store.gemspec'
38
+
39
+ # Offense count: 1
40
+ # This cop supports safe autocorrection (--autocorrect).
41
+ Gemspec/RequireMFA:
42
+ Exclude:
43
+ - 'mongo_session_store.gemspec'
44
+
45
+ # Offense count: 1
46
+ Gemspec/RequiredRubyVersion:
47
+ Exclude:
48
+ - 'mongo_session_store.gemspec'
49
+
50
+ # Offense count: 1
51
+ # This cop supports safe autocorrection (--autocorrect).
52
+ Layout/EmptyLineAfterGuardClause:
53
+ Exclude:
54
+ - 'lib/mongo_session_store/mongo_store.rb'
55
+
56
+ # Offense count: 2
57
+ # This cop supports safe autocorrection (--autocorrect).
58
+ # Configuration parameters: EnforcedStyle.
59
+ # SupportedStyles: space, no_space
60
+ Layout/LineContinuationSpacing:
61
+ Exclude:
62
+ - 'lib/mongo_session_store/mongo_store.rb'
63
+
64
+ # Offense count: 1
65
+ # This cop supports safe autocorrection (--autocorrect).
66
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
67
+ # SupportedStyles: aligned, indented
68
+ Layout/LineEndStringConcatenationIndentation:
69
+ Exclude:
70
+ - 'lib/mongo_session_store/mongo_store.rb'
71
+
72
+ # Offense count: 5
73
+ # This cop supports safe autocorrection (--autocorrect).
74
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
75
+ Lint/AmbiguousBlockAssociation:
76
+ Exclude:
77
+ - 'spec/lib/mongo_session_store/mongo_store/session_spec.rb'
78
+ - 'spec/lib/mongo_session_store/mongo_store_base_spec.rb'
79
+
80
+ # Offense count: 3
81
+ # Configuration parameters: AllowedMethods.
82
+ # AllowedMethods: enums
83
+ Lint/ConstantDefinitionInBlock:
84
+ Exclude:
85
+ - 'Rakefile'
86
+
87
+ # Offense count: 17
88
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
89
+ # AllowedMethods: refine
90
+ Metrics/BlockLength:
91
+ Max: 215
92
+
93
+ # Offense count: 12
94
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
95
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
96
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
97
+ Naming/FileName:
98
+ Exclude:
99
+ - 'Rakefile.rb'
100
+ - 'gemfiles/rails-5.0-mongo.gemfile'
101
+ - 'gemfiles/rails-5.0-mongoid.gemfile'
102
+ - 'gemfiles/rails-5.1-mongo.gemfile'
103
+ - 'gemfiles/rails-5.1-mongoid.gemfile'
104
+ - 'gemfiles/rails-5.2-mongo.gemfile'
105
+ - 'gemfiles/rails-5.2-mongoid.gemfile'
106
+ - 'gemfiles/rails-6.0-mongo.gemfile'
107
+ - 'gemfiles/rails-6.0-mongoid.gemfile'
108
+ - 'gemfiles/rails-8.1-mongo.gemfile'
109
+ - 'gemfiles/rails-8.1-mongoid.gemfile'
110
+ - 'gemfiles/rails-current-mongo.gemfile'
111
+ - 'gemfiles/rails-current-mongoid.gemfile'
112
+
113
+ # Offense count: 5
114
+ Security/MarshalLoad:
115
+ Exclude:
116
+ - 'lib/mongo_session_store/mongo_store.rb'
117
+ - 'lib/mongo_session_store/mongoid_store.rb'
118
+ - 'spec/lib/mongo_session_store/mongo_store/session_spec.rb'
119
+
120
+ # Offense count: 34
121
+ # This cop supports unsafe autocorrection (--autocorrect-all).
122
+ # Configuration parameters: EnforcedStyle.
123
+ # SupportedStyles: always, always_true, never
124
+ Style/FrozenStringLiteralComment:
125
+ Enabled: false
126
+
127
+ # Offense count: 1
128
+ # This cop supports safe autocorrection (--autocorrect).
129
+ # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
130
+ Style/GuardClause:
131
+ Exclude:
132
+ - 'Rakefile'
133
+
134
+ # Offense count: 1
135
+ # This cop supports safe autocorrection (--autocorrect).
136
+ # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
137
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
138
+ # SupportedShorthandSyntax: always, never, either, consistent, either_consistent
139
+ Style/HashSyntax:
140
+ Exclude:
141
+ - 'Dangerfile'
142
+
143
+ # Offense count: 1
144
+ # This cop supports safe autocorrection (--autocorrect).
145
+ Style/IfUnlessModifier:
146
+ Exclude:
147
+ - 'Rakefile'
148
+
149
+ # Offense count: 1
150
+ # This cop supports unsafe autocorrection (--autocorrect-all).
151
+ # Configuration parameters: InverseMethods, InverseBlocks.
152
+ Style/InverseMethods:
153
+ Exclude:
154
+ - 'spec/support/helpers/test_database_helper.rb'
155
+
156
+ # Offense count: 3
157
+ # This cop supports unsafe autocorrection (--autocorrect-all).
158
+ # Configuration parameters: EnforcedStyle, Recursive.
159
+ # SupportedStyles: literals, strict
160
+ Style/MutableConstant:
161
+ Exclude:
162
+ - 'Rakefile'
163
+
164
+ # Offense count: 1
165
+ Style/OpenStructUse:
166
+ Exclude:
167
+ - 'spec/lib/mongo_session_store/mongo_store_base_spec.rb'
168
+
169
+ # Offense count: 1
170
+ # This cop supports safe autocorrection (--autocorrect).
171
+ Style/RedundantConstantBase:
172
+ Exclude:
173
+ - 'spec/spec_helper.rb'
174
+
175
+ # Offense count: 1
176
+ # This cop supports safe autocorrection (--autocorrect).
177
+ Style/RedundantParentheses:
178
+ Exclude:
179
+ - 'lib/mongo_session_store/mongo_store_base.rb'
180
+
181
+ # Offense count: 1
182
+ # This cop supports safe autocorrection (--autocorrect).
183
+ # Configuration parameters: EnforcedStyle.
184
+ # SupportedStyles: implicit, explicit
185
+ Style/RescueStandardError:
186
+ Exclude:
187
+ - 'Rakefile'
188
+
189
+ # Offense count: 1
190
+ # This cop supports safe autocorrection (--autocorrect).
191
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
192
+ # SupportedStyles: single_quotes, double_quotes
193
+ Style/StringLiterals:
194
+ Exclude:
195
+ - 'Dangerfile'
data/CHANGELOG.md CHANGED
@@ -1,28 +1,33 @@
1
- # Changelog
1
+ ### 3.3.0 (2026/10/18)
2
2
 
3
- ## 3.2.2 (2026/10/14)
3
+ * [#57](https://github.com/mongoid/mongo_session_store/pull/57): Cover legacy session decoding and fix private decoder delegation in the plain-driver adapter - [@dblock](https://github.com/dblock).
4
+ * [#55](https://github.com/mongoid/mongo_session_store/pull/55): Add explicit bulk stale-session cleanup with an application-selected cutoff for both adapters - [@dblock](https://github.com/dblock).
5
+ * [#54](https://github.com/mongoid/mongo_session_store/pull/54): Document and test storing permitted parameter hashes rather than request-bearing Rails parameter objects in sessions - [@dblock](https://github.com/dblock).
6
+ * [#53](https://github.com/mongoid/mongo_session_store/pull/53): Cover Rails 6.1 through 8.0 in CI, update RuboCop, isolate Danger permissions, and report both adapters' coverage to Coveralls - [@dblock](https://github.com/dblock).
7
+
8
+ ### 3.2.2 (2026/10/14)
4
9
 
5
10
  * [#51](https://github.com/mongoid/mongo_session_store/pull/51): Modernize CI through Ruby 4.0, Rails 8.1, Mongoid 9 and MongoDB 8 while retaining legacy Rails combinations - [@dblock](https://github.com/dblock).
6
- * [#51](https://github.com/mongoid/mongo_session_store/pull/51): Explicitly load ActionDispatch before defining the session store.
11
+ * [#51](https://github.com/mongoid/mongo_session_store/pull/51): Explicitly load ActionDispatch before defining the session store - [@dblock](https://github.com/dblock).
7
12
  * [#48](https://github.com/mongoid/mongo_session_store/pull/48): Migrate Danger to danger-pr-comment - [@dblock](https://github.com/dblock).
8
13
 
9
- ## 3.2.1
14
+ ### 3.2.1 (2020/04/27)
10
15
 
11
16
  * [#45](https://github.com/mongoid/mongo_session_store/pull/45): Add Rails 6.0 to test setup - [@tombruijn](https://github.com/tombruijn).
12
17
  * [#46](https://github.com/mongoid/mongo_session_store/pull/46): Fix Rack::Session::Cookie middleware bug - [@streetlogics](https://github.com/streetlogics) & [@tombruijn](https://github.com/tombruijn).
13
18
 
14
- ## 3.2.0
19
+ ### 3.2.0 (2019/04/26)
15
20
 
16
21
  * [#32](https://github.com/mongoid/mongo_session_store/pull/32): Add Rails 5.1 support - [@tombruijn](https://github.com/tombruijn).
17
22
  * [#36](https://github.com/mongoid/mongo_session_store/pull/36): Add gem specific main error class - [@tombruijn](https://github.com/tombruijn).
18
23
  * [#38](https://github.com/mongoid/mongo_session_store/pull/38): Support rails 5.2 - [@tombruijn](https://github.com/tombruijn).
19
24
  * [#41](https://github.com/mongoid/mongo_session_store/pull/41): Add Ruby 2.5 and 2.6 support - [@tombruijn](https://github.com/tombruijn).
20
25
 
21
- ## 3.1.0
26
+ ### 3.1.0 (2017/05/02)
22
27
 
23
28
  * [#31](https://github.com/mongoid/mongo_session_store/pull/31): Add Rails 5.0 support - [@tombruijn](https://github.com/tombruijn).
24
29
 
25
- ## 3.0.0
30
+ ### 3.0.0 (2017/04/27)
26
31
 
27
32
  * Drop Ruby 1.8, 1.9 and 2.0 support - [@tombruijn](https://github.com/tombruijn).
28
33
  * Drop explicit MongoMapper support - [@tombruijn](https://github.com/tombruijn).
@@ -41,7 +46,7 @@
41
46
  * [#28](https://github.com/mongoid/mongo_session_store/pull/28): Support Ruby 2.4 - [@tombruijn](https://github.com/tombruijn).
42
47
  * [#29](https://github.com/mongoid/mongo_session_store/pull/29): Use rails default session id generation - [@tombruijn](https://github.com/tombruijn).
43
48
 
44
- ## 2.0.0
49
+ ### 2.0.0 (2010/10/13)
45
50
 
46
51
  * Fix MongoMapper indexes - [@nmerouze](https://github.com/nmerouze).
47
52
  * Add Rails 3 support for Mongoid - [@nmerouze](https://github.com/nmerouze).
@@ -49,23 +54,23 @@
49
54
  * Support MongoMapper 0.7.5 - [@hsbt](https://github.com/hsbt).
50
55
  * Fix issue where ActionPack expects `set_session` to return the (new) session_id when session is created successfully - [@memuller](https://github.com/memuller).
51
56
 
52
- ## 1.1.2
57
+ ### 1.1.2 (2010/03/05)
53
58
 
54
59
  * Generate a new session document if the current session document doesn't exist - [@shingara](https://github.com/shingara).
55
60
 
56
- ## 1.1.1
61
+ ### 1.1.1 (2010/02/21)
57
62
 
58
63
  * Fix `updated_at` index for MongoMapper session documents - [@nmerouze](https://github.com/nmerouze).
59
64
 
60
- ## 1.1.0
65
+ ### 1.1.0 (2010/02/17)
61
66
 
62
67
  * Add Mongoid support - [@nmerouze](https://github.com/nmerouze).
63
68
 
64
- ## 1.0.1
69
+ ### 1.0.1 (2010/01/22)
65
70
 
66
71
  * Add gemspec and specify actionpack dependency - [@nmerouze](https://github.com/nmerouze).
67
72
 
68
- ## 1.0.0
73
+ ### 1.0.0 (2010/01/22)
69
74
 
70
75
  * Initial version of the gem - [@tpitale](https://github.com/tpitale), [@compressed](https://github.com/compressed).
71
76
  * MongoMapper session store support - [@tpitale](https://github.com/tpitale), [@compressed](https://github.com/compressed).
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rubocop", "1.84.1"
5
+ gem "rubocop", "1.92.0"
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # MongoSessionStore
2
2
 
3
- [![Build Status](https://travis-ci.org/mongoid/mongo_session_store.svg?branch=master)](https://travis-ci.org/mongoid/mongo_session_store)
3
+ [![CI](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml?query=branch%3Amain)
4
4
  [![Gem Version](https://badge.fury.io/rb/mongo_session_store.svg)](http://badge.fury.io/rb/mongo_session_store)
5
- [![Code Climate](https://codeclimate.com/github/mongoid/mongo_session_store/badges/gpa.svg)](https://codeclimate.com/github/mongoid/mongo_session_store)
5
+ [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongo_session_store/badge.svg?branch=main)](https://coveralls.io/github/mongoid/mongo_session_store?branch=main)
6
6
 
7
7
  ## Description
8
8
 
@@ -68,6 +68,40 @@ MongoidStore::Session.where(:updated_at.gt => 2.days.ago)
68
68
  MongoStore::Session.where("updated_at" => { "$gt" => 2.days.ago })
69
69
  ```
70
70
 
71
+ ### Serializable session values
72
+
73
+ Both adapters serialize session data with Ruby's `Marshal`. Store serializable values such as strings, numbers, arrays, and hashes, not requests, input streams, or uploaded files. Serialization errors are raised rather than silently discarding data.
74
+
75
+ Do not store `ActionController::Parameters` objects directly in the session. On Rails 7 and newer, their logging context can retain the request and its input stream, causing `TypeError: can't dump IO` (or a similar error for `StringIO`). A nested `params[:search]` object can retain that context too. Explicitly permit the values your application needs and convert them to a hash before saving:
76
+
77
+ ```ruby
78
+ session[:search] = params.require(:search).permit(:query, :sort).to_h
79
+ ```
80
+
81
+ This stores the permitted values without the request context. It does not make uploaded files or other non-serializable values serializable; store a durable identifier for those instead.
82
+
83
+ ### Deleting stale sessions
84
+
85
+ Sessions are not automatically expired or deleted. To opt in to cleanup, call the store's `delete_stale_sessions` method with an explicit `Time` cutoff:
86
+
87
+ ```ruby
88
+ # Mongoid
89
+ MongoidStore.delete_stale_sessions(before: 1.week.ago)
90
+
91
+ # MongoDB Ruby Driver
92
+ MongoStore.delete_stale_sessions(before: 1.week.ago)
93
+ ```
94
+
95
+ The method returns the number deleted and uses the configured session collection. It performs a bulk database deletion without loading session data or running model callbacks. Only records whose `updated_at` is strictly earlier than the cutoff are deleted; records at the cutoff or without a timestamp are retained. Invalid cutoffs raise `ArgumentError`, and database errors propagate to the caller.
96
+
97
+ Run cleanup explicitly from a scheduled job or a Rails runner command, choosing a retention policy appropriate for your application:
98
+
99
+ ```sh
100
+ bin/rails runner 'MongoidStore.delete_stale_sessions(before: 1.week.ago)'
101
+ ```
102
+
103
+ Deleting a session signs that session out on its next request. Cleanup is not cookie expiration or a guarantee of inactivity-based logout: `updated_at` tracks session saves, and a request that does not save the session may not refresh it. No default maximum age, background job, or TTL index is installed. For large collections, consider creating an ordinary index on `updated_at` as part of your database setup.
104
+
71
105
  ## Development
72
106
 
73
107
  ### Test environment
@@ -102,6 +136,16 @@ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile bundle exec rake
102
136
  BUNDLE_GEMFILE=gemfiles/rails-6.0-mongoid.gemfile bundle exec rake
103
137
  ```
104
138
 
139
+ For Rails 6.1 and newer, use `gemfiles/rails-current-mongo.gemfile` or `gemfiles/rails-current-mongoid.gemfile` with `RAILS_VERSION` and, for Mongoid, `MONGOID_VERSION` constraints:
140
+
141
+ ```sh
142
+ RAILS_VERSION='~> 7.2.0' MONGOID_VERSION='~> 9.0' BUNDLE_GEMFILE=gemfiles/rails-current-mongoid.gemfile bundle exec rake test
143
+ ```
144
+
145
+ For Rails 8.0, also set `SQLITE_VERSION='~> 2.1'`; the dedicated Rails 8.1 Gemfiles already select SQLite 2.
146
+
147
+ Set `MONGODB_HOST` and `MONGODB_PORT` to use a non-default test server. The default is `127.0.0.1:27017`.
148
+
105
149
  #### Docker testing
106
150
 
107
151
  To run tests in a Docker container with a specific Ruby version and gemfile:
@@ -161,6 +205,3 @@ Released under the MIT license. See the [LICENSE](LICENSE) file.
161
205
  [rails]: http://rubyonrails.org/
162
206
 
163
207
  [issue-rails3]: https://github.com/mongoid/mongo_session_store/issues/17
164
- ## CI compatibility
165
-
166
- CI retains the Rails 5.0–6.0 dependency files and exercises both Mongo and Mongoid session stores with Rails 8.1, Mongoid 9, Ruby 3.4/4.0 and MongoDB 8.0; use `BUNDLE_GEMFILE=gemfiles/rails-8.1-mongoid.gemfile bundle exec rake test` for the modern Mongoid suite, which shares the minimal Rails 6 integration app.
@@ -10,5 +10,6 @@ gem "drb"
10
10
  gem "base64"
11
11
  gem "benchmark"
12
12
  gem "ostruct"
13
+ gem "simplecov", "~> 0.22", :require => false
13
14
 
14
15
  gemspec :path => "../"
@@ -10,5 +10,6 @@ gem "drb"
10
10
  gem "base64"
11
11
  gem "benchmark"
12
12
  gem "ostruct"
13
+ gem "simplecov", "~> 0.22", :require => false
13
14
 
14
15
  gemspec :path => "../"
@@ -0,0 +1,16 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", ENV.fetch("RAILS_VERSION", "~> 7.2.0")
4
+ gem "mongo", "~> 2.0"
5
+ gem "devise", "~> 4.9"
6
+ gem "sqlite3", ENV.fetch("SQLITE_VERSION", "~> 1.4")
7
+ gem "logger"
8
+ gem "bigdecimal"
9
+ gem "mutex_m"
10
+ gem "drb"
11
+ gem "base64"
12
+ gem "benchmark"
13
+ gem "ostruct"
14
+ gem "simplecov", "~> 0.22", :require => false if ENV["COVERAGE"] == "true"
15
+
16
+ gemspec :path => "../"
@@ -0,0 +1,3 @@
1
+ eval_gemfile "rails-current-mongo.gemfile"
2
+
3
+ gem "mongoid", ENV.fetch("MONGOID_VERSION", "~> 9.0")
@@ -92,7 +92,7 @@ module ActionDispatch
92
92
  end
93
93
 
94
94
  def unpack(packed)
95
- self.class.unpack(packed)
95
+ self.class.send(:unpack, packed)
96
96
  end
97
97
  end
98
98
  end
@@ -16,6 +16,12 @@ module ActionDispatch
16
16
  self::Session
17
17
  end
18
18
 
19
+ def self.delete_stale_sessions(before:)
20
+ raise ArgumentError, "before must be a Time" unless before.is_a?(Time)
21
+
22
+ session_class.collection.find("updated_at" => { "$lt" => before.getutc }).delete_many.deleted_count
23
+ end
24
+
19
25
  private
20
26
 
21
27
  def session_class
@@ -1,3 +1,3 @@
1
1
  module MongoSessionStore
2
- VERSION = "3.2.2".freeze
2
+ VERSION = "3.3.0".freeze
3
3
  end
data/spec/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  inherit_from: ../.rubocop.yml
2
2
 
3
- Metrics/LineLength:
3
+ Layout/LineLength:
4
4
  Max: 100
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe "Legacy session serialization" do
4
+ let(:session_class) { mongo_orm == "mongoid" ? MongoidStore::Session : MongoStore::Session }
5
+
6
+ it "reads raw marshalled strings as well as BSON binary data" do
7
+ payload = { "nested" => { "count" => 2 }, "tags" => %w[old session] }
8
+ session = session_class.new
9
+
10
+ expect(session.send(:unpack, Marshal.dump(payload))).to eq(payload)
11
+ expect(session.send(:unpack, BSON::Binary.new(Marshal.dump(payload), :generic))).to eq(payload)
12
+ end
13
+
14
+ it "returns nil when there is no serialized payload" do
15
+ expect(session_class.new.send(:unpack, nil)).to be_nil
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ require "rails_helper"
2
+
3
+ describe "Session data serialization" do
4
+ let(:session_class) { mongo_orm == "mongoid" ? MongoidStore::Session : MongoStore::Session }
5
+ let(:id) { generate_sid }
6
+ let(:search) { { "query" => "painting", "admin" => "1" } }
7
+ let(:parameters) do
8
+ values = { "search" => search }
9
+ if Gem.loaded_specs["rails"].version >= Gem::Version.new("7.0")
10
+ request = ActionDispatch::TestRequest.create("rack.input" => StringIO.new)
11
+ ActionController::Parameters.new(values, :request => request)
12
+ else
13
+ ActionController::Parameters.new(values)
14
+ end
15
+ end
16
+
17
+ it "round-trips explicitly permitted parameter values without request context" do
18
+ record = session_class.new(:_id => id)
19
+ record.data = { "search" => parameters.require(:search).permit(:query).to_h }
20
+ record.save
21
+
22
+ expect(session_class.where(:_id => id).first.data).to eq(
23
+ "search" => { "query" => "painting" }
24
+ )
25
+ end
26
+
27
+ if Gem.loaded_specs["rails"].version >= Gem::Version.new("7.0")
28
+ it "reports serialization errors for raw parameters retaining an input stream" do
29
+ record = session_class.new(:_id => id)
30
+ record.data = { "search" => parameters[:search] }
31
+
32
+ expect { record.save }.to raise_error(TypeError, /StringIO/)
33
+ expect(session_class.collection.find(:_id => id).count).to eq(0)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,77 @@
1
+ require "spec_helper"
2
+
3
+ describe ".delete_stale_sessions" do
4
+ let(:store) { mongo_orm == "mongoid" ? MongoidStore : MongoStore }
5
+ let(:collection) { store.session_class.collection }
6
+ let(:cutoff) { Time.utc(2026, 1, 1) }
7
+
8
+ it "deletes only sessions last updated strictly before the cutoff" do
9
+ collection.insert_many([
10
+ { :_id => "stale", :updated_at => cutoff - 1 },
11
+ { :_id => "boundary", :updated_at => cutoff },
12
+ { :_id => "active", :created_at => cutoff - 100, :updated_at => cutoff + 1 },
13
+ { :_id => "undated" },
14
+ { :_id => "null-date", :updated_at => nil }
15
+ ])
16
+
17
+ expect(store.delete_stale_sessions(:before => cutoff)).to eq(1)
18
+ expect(collection.find.map { |doc| doc["_id"] }.sort).to eq(
19
+ %w[active boundary null-date undated]
20
+ )
21
+ expect(store.delete_stale_sessions(:before => cutoff)).to eq(0)
22
+ end
23
+
24
+ it "returns zero for an empty collection" do
25
+ expect(store.delete_stale_sessions(:before => cutoff)).to eq(0)
26
+ end
27
+
28
+ it "accepts a cutoff with a UTC offset" do
29
+ collection.insert_one(:_id => "stale", :updated_at => cutoff - 1)
30
+ local_cutoff = cutoff.getlocal("-05:00")
31
+
32
+ expect(store.delete_stale_sessions(:before => local_cutoff)).to eq(1)
33
+ expect(local_cutoff.utc_offset).to eq(-5 * 60 * 60)
34
+ end
35
+
36
+ it "accepts a Rails time-zone cutoff" do
37
+ collection.insert_one(:_id => "stale", :updated_at => cutoff - 1)
38
+ zoned_cutoff = cutoff.in_time_zone("Eastern Time (US & Canada)")
39
+ expect(store.delete_stale_sessions(:before => zoned_cutoff)).to eq(1)
40
+ end
41
+
42
+ it "rejects invalid cutoffs without deleting sessions" do
43
+ collection.insert_one(:_id => "stale", :updated_at => cutoff - 1)
44
+
45
+ [nil, "2026-01-01", 1].each do |value|
46
+ expect { store.delete_stale_sessions(:before => value) }.to raise_error(
47
+ ArgumentError, "before must be a Time"
48
+ )
49
+ end
50
+ expect(collection.find.count).to eq(1)
51
+ end
52
+
53
+ it "uses the configured collection without touching the default collection" do
54
+ collection.insert_one(:_id => "default", :updated_at => cutoff - 1)
55
+ original_name = MongoSessionStore.collection_name
56
+ begin
57
+ MongoSessionStore.collection_name = "custom_sessions"
58
+ custom_collection = store.session_class.collection
59
+ custom_collection.insert_one(:_id => "custom", :updated_at => cutoff - 1)
60
+
61
+ expect(store.delete_stale_sessions(:before => cutoff)).to eq(1)
62
+ expect(custom_collection.find.count).to eq(0)
63
+ ensure
64
+ MongoSessionStore.collection_name = original_name
65
+ end
66
+ expect(collection.find.count).to eq(1)
67
+ end
68
+
69
+ it "does not suppress database errors" do
70
+ allow(store.session_class).to receive(:collection)
71
+ .and_raise(MongoSessionStore::Error, "unavailable")
72
+
73
+ expect { store.delete_stale_sessions(:before => cutoff) }.to raise_error(
74
+ MongoSessionStore::Error, "unavailable"
75
+ )
76
+ end
77
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe MongoSessionStore do
4
+ it "defines a frozen semantic version" do
5
+ expect(MongoSessionStore::VERSION).to match(/\A\d+\.\d+\.\d+\z/)
6
+ expect(MongoSessionStore::VERSION).to be_frozen
7
+ end
8
+ end
data/spec/rails_helper.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
+ require "logger"
3
+ require "active_support"
2
4
  rails_version = Gem.loaded_specs["rails"].version.to_s[/^\d\.\d/]
3
- # Modern Rails uses the same minimal integration app as Rails 6.
4
- rails_version = "6.0" if Gem.loaded_specs["rails"].version >= Gem::Version.new("7.0")
5
+ # Later Rails versions use the same minimal integration app as Rails 6.
6
+ rails_version = "6.0" if Gem.loaded_specs["rails"].version >= Gem::Version.new("6.0")
5
7
  if Gem.loaded_specs["rails"].version >= Gem::Version.new("5.2")
6
8
  require "active_support/message_encryptor"
7
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,12 @@
1
+ if ENV["COVERAGE"] == "true"
2
+ require "simplecov"
3
+ SimpleCov.command_name "RSpec #{Gem.loaded_specs.key?("mongoid") ? "Mongoid" : "Mongo"}"
4
+ SimpleCov.start do
5
+ track_files "lib/**/*.rb"
6
+ add_filter "/spec/"
7
+ end
8
+ end
9
+
1
10
  require "logger"
2
11
  require "mongo"
3
12
  require "mongoid" if Gem.loaded_specs["mongoid"]
@@ -29,6 +38,7 @@ RSpec.configure do |config|
29
38
  Mongo::Logger.logger.level = ::Logger::INFO
30
39
 
31
40
  mongodb_host = ENV["MONGODB_HOST"] || "127.0.0.1"
41
+ mongodb_port = ENV["MONGODB_PORT"] || "27017"
32
42
  if mongo_orm == "mongoid"
33
43
  Mongoid.logger.level = Logger::INFO
34
44
  Mongoid.configure do |c|
@@ -36,14 +46,14 @@ RSpec.configure do |config|
36
46
  "clients" => {
37
47
  "default" => {
38
48
  "database" => TestDatabaseHelper.test_database_name,
39
- "hosts" => ["#{mongodb_host}:27017"]
49
+ "hosts" => ["#{mongodb_host}:#{mongodb_port}"]
40
50
  }
41
51
  }
42
52
  )
43
53
  end
44
54
  else
45
55
  MongoStore::Session.database = Mongo::Client.new(
46
- ["#{mongodb_host}:27017"],
56
+ ["#{mongodb_host}:#{mongodb_port}"],
47
57
  :database => TestDatabaseHelper.test_database_name
48
58
  )
49
59
  end
@@ -6,9 +6,7 @@ module TestDatabaseHelper
6
6
  when "mongoid"
7
7
  MongoidStore::Session.mongo_client
8
8
  when "mongo"
9
- Mongo::Client
10
- .new(["127.0.0.1:27017"], :database => test_database_name)
11
- .database
9
+ MongoStore::Session.database.database
12
10
  end
13
11
  end
14
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_session_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Bruijn
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2026-10-15 00:00:00.000000000 Z
15
+ date: 2026-10-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionpack
@@ -97,6 +97,7 @@ files:
97
97
  - ".gitignore"
98
98
  - ".rspec"
99
99
  - ".rubocop.yml"
100
+ - ".rubocop_todo.yml"
100
101
  - CHANGELOG.md
101
102
  - Dangerfile
102
103
  - Gemfile
@@ -116,6 +117,8 @@ files:
116
117
  - gemfiles/rails-6.0-mongoid.gemfile
117
118
  - gemfiles/rails-8.1-mongo.gemfile
118
119
  - gemfiles/rails-8.1-mongoid.gemfile
120
+ - gemfiles/rails-current-mongo.gemfile
121
+ - gemfiles/rails-current-mongoid.gemfile
119
122
  - lib/mongo_session_store.rb
120
123
  - lib/mongo_session_store/mongo_store.rb
121
124
  - lib/mongo_session_store/mongo_store_base.rb
@@ -129,11 +132,15 @@ files:
129
132
  - spec/.rubocop.yml
130
133
  - spec/integrations/devise_spec.rb
131
134
  - spec/integrations/rack_spec.rb
135
+ - spec/lib/mongo_session_store/legacy_serialization_spec.rb
132
136
  - spec/lib/mongo_session_store/mongo_store/session_spec.rb
133
137
  - spec/lib/mongo_session_store/mongo_store_base_spec.rb
134
138
  - spec/lib/mongo_session_store/mongo_store_spec.rb
135
139
  - spec/lib/mongo_session_store/mongoid_store/session_spec.rb
136
140
  - spec/lib/mongo_session_store/mongoid_store_spec.rb
141
+ - spec/lib/mongo_session_store/serialization_spec.rb
142
+ - spec/lib/mongo_session_store/stale_sessions_spec.rb
143
+ - spec/lib/mongo_session_store/version_spec.rb
137
144
  - spec/lib/mongo_session_store_spec.rb
138
145
  - spec/rails_helper.rb
139
146
  - spec/spec_helper.rb
@@ -289,11 +296,15 @@ test_files:
289
296
  - perf/benchmark.rb
290
297
  - spec/integrations/devise_spec.rb
291
298
  - spec/integrations/rack_spec.rb
299
+ - spec/lib/mongo_session_store/legacy_serialization_spec.rb
292
300
  - spec/lib/mongo_session_store/mongo_store/session_spec.rb
293
301
  - spec/lib/mongo_session_store/mongo_store_base_spec.rb
294
302
  - spec/lib/mongo_session_store/mongo_store_spec.rb
295
303
  - spec/lib/mongo_session_store/mongoid_store/session_spec.rb
296
304
  - spec/lib/mongo_session_store/mongoid_store_spec.rb
305
+ - spec/lib/mongo_session_store/serialization_spec.rb
306
+ - spec/lib/mongo_session_store/stale_sessions_spec.rb
307
+ - spec/lib/mongo_session_store/version_spec.rb
297
308
  - spec/lib/mongo_session_store_spec.rb
298
309
  - spec/rails_helper.rb
299
310
  - spec/spec_helper.rb