limited_sessions 4.1.0 → 4.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
  SHA1:
3
- metadata.gz: a14e5b8ce5202da6e1452b2841774f4cdae0d57d
4
- data.tar.gz: e075a3d2ce01c91352a926be7ec5b9952ccca9fb
3
+ metadata.gz: 72435a434d8e6fb836b3aa85fb4d53d5e09032ad
4
+ data.tar.gz: 8344fca106d43399d81d71aeb30d2b1fbf4c450a
5
5
  SHA512:
6
- metadata.gz: c3b6973575a2129f8065448e7e9d96ee8dec26f8294d2c143d3c0d2af246d85c90e7909366f59a6dc1472c9912eaba79a79beca2fcabafeee589160888cb3c49
7
- data.tar.gz: 71fb03540633023b30fe6bdcc53ac79143f66b25cab453fc57bf5f3c1ed1c32049c594bcf976d1d25eb028db7bde8be7a0afbfa76e77138ecd1ec21e8a0be35e
6
+ metadata.gz: 353a235142ff978cf4fae93899d3d64af32dec47fbdef58e7045d47dc7842c9a51b1dfa2f1e2b5407ee309efa0bf6bc535dd45aeb91457b07f04955d3346a7b5
7
+ data.tar.gz: b7aefc332194cc4176ed4322325d20ba41715de602f5e28e3f43a020e69307770e3160359ea1545e86fb2a4b95c759bb7f14b56a8cda8d3b4a867f3b0ce2e433
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ * 2017-may-22 - v4.2.0
2
+
3
+ - Fixed ActiveRecord session cleanup on Rails 5.1
4
+ - Prevent ActiveRecord session cleanup from possibly running more often than
5
+ configured due to Rails loading sessions more than once per request.
6
+
1
7
  * 2016-feb-12 - v4.1.0
2
8
 
3
9
  - Support Rails 5.0 & Rack 2.0
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  LimitedSessions
2
2
  ===============
3
- Copyright 2007-2013 t.e.morgan.
3
+ Copyright 2007-2017 t.e.morgan.
4
4
  License: MIT
5
5
 
6
6
  Updates/info: http://iprog.com/projects#limited_sessions
@@ -10,23 +10,27 @@ Contact: tm@iprog.com
10
10
 
11
11
  LimitedSessions provides two distinct features, each in a separate part:
12
12
  * Rack-compatible middleware that expires sessions based on inactivity or
13
- maximum session length. This works with Rails 4 just fine.
14
- * Rails 4 extension to the (now separate) ActiveRecord Session Store to
13
+ maximum session length. The middleware supports any session storage type,
14
+ including cookies, Redis, ActiveRecord, etc.
15
+ * Rails 4+ extension to the (now separate) ActiveRecord Session Store to
15
16
  auto-cleanup stale session records.
16
17
 
17
18
 
18
19
  Notes on Rails and Rack versions:
19
20
  The middleware should be compatible with any framework using a recent
20
- version of Rack. It was tested with Rack 1.5 and Rails 4.0.
21
+ version of Rack. It was tested with Rack 1.5 on Rails 4.2 and Rack 2.0 on
22
+ Rails 5.0 and 5.1.
21
23
 
22
- The ActiveRecord Session Store extension requires Rails 4 and the now
24
+ The ActiveRecord Session Store extension requires Rails 4+ and the now
23
25
  separate activerecord-session_store gem:
24
26
  gem 'activerecord-session_store'
25
27
  activerecord-session_store must be *before* limited_sessions in your Gemfile
26
28
  in order for limited_sessions to auto-detect it.
27
29
 
28
- For Rails 3, use limited_sessions v3.x.x:
29
- gem 'limited_sessions', '~> 3.0'
30
+ The extension has been tested with the following combinations:
31
+ * Rails 4.2 + activerecord-session_store 0.1.2
32
+ * Rails 5.0 + activerecord-session_store 1.0.0
33
+ * Rails 5.1 + activerecord-session_store 1.1.0
30
34
 
31
35
 
32
36
  Upgrading from previous versions:
@@ -49,7 +53,7 @@ Features:
49
53
 
50
54
 
51
55
  Requirements:
52
- * Rack and any Rack-compatible app (including Rails 4)
56
+ * Rack and any Rack-compatible app (including Rails 4 or 5)
53
57
  * Utilizing Rack's (or Rails') sessions support
54
58
  * For ActiveRecord session enhancements:
55
59
  * Must be using the standard ActiveRecord::SessionStore
@@ -218,12 +222,11 @@ Other questions:
218
222
 
219
223
 
220
224
  Other Notes:
221
- This version has been tested on Rack 1.5 and Rails 4.0. It should be
225
+ This version has been tested on Rack 1.5-2.0 and Rails 4.2-5.1. It should be
222
226
  compatible with a broad spectrum of data and session stores. If you find a
223
227
  bug, I'd love to hear about it -- preferably via a new issue on GitHub (bonus
224
228
  points for a pull request). Likewise, give me a shout if you have a suggestion
225
229
  or just want to tell me that it works. Thanks for checking limited_sessions
226
230
  out!
227
231
 
228
- --t (tm@iprog.com; http://iprog.com/)
229
-
232
+ --t (tm@iprog.com; https://iprog.com/)
@@ -1,9 +1,9 @@
1
1
  # LimitedSessions
2
- # (c) 2007-2013 t.e.morgan
2
+ # (c) 2007-2017 t.e.morgan
3
3
  # Made available under the MIT license
4
4
 
5
- # This version is compatible with Rack 1.4-1.5 (possibly earlier; untested).
6
- # Correspondingly, it is compatible with Rails 3.x-4.x.
5
+ # This version is compatible with Rack 1.4-2.0 (possibly earlier; untested).
6
+ # Correspondingly, it is compatible with Rails 3.x-5.x.
7
7
 
8
8
  module LimitedSessions
9
9
  # Rack middleware that should be installed *after* the session handling middleware
@@ -1,8 +1,8 @@
1
1
  # LimitedSessions
2
- # (c) 2007-2012 t.e.morgan
2
+ # (c) 2007-2017 t.e.morgan
3
3
  # Made available under the MIT license
4
4
 
5
- # This is the Rails 4.x version.
5
+ # This is the Rails 4-5.x version.
6
6
 
7
7
  module LimitedSessions
8
8
  class SelfCleaningSession < ActiveRecord::SessionStore::Session
@@ -35,13 +35,15 @@ module LimitedSessions
35
35
  private
36
36
  def consider_self_clean
37
37
  return if self_clean_sessions == 0
38
+ return if defined?(@@last_check) && @@last_check == Time.now.to_i
38
39
  if rand(self_clean_sessions) == 0
40
+ @@last_check = Time.now.to_i
39
41
  # logger.info "SelfCleaningSession :: scrubbing expired sessions"
40
42
  look_back_recent = recent_activity || 1.week
41
43
  if max_session
42
- delete_all ['updated_at < ? OR created_at < ?', Time.current - look_back_recent, Time.current - max_session]
44
+ self.where('updated_at < ? OR created_at < ?', Time.current - look_back_recent, Time.current - max_session).delete_all
43
45
  elsif columns_hash['updated_at']
44
- delete_all ['updated_at < ?', Time.current - look_back_recent]
46
+ self.where('updated_at < ?', Time.current - look_back_recent).delete_all
45
47
  else
46
48
  # logger.warning "WARNING: Unable to self-clean Sessions table; updated_at column is missing"
47
49
  self.self_clean_sessions = 0
@@ -1,3 +1,3 @@
1
1
  module LimitedSessions
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: limited_sessions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - t.e.morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '4.0'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '5.1'
56
+ version: '5.2'
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ dependencies:
63
63
  version: '4.0'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '5.1'
66
+ version: '5.2'
67
67
  description: 'LimitedSessions provides two core features to handle cookie-based session
68
68
  expiry: 1) Rack Middleware for most session stores and 2) an ActiveRecord extension
69
69
  for AR-based session stores. Sessions can be expired on inactivity and/or overall
@@ -114,7 +114,7 @@ files:
114
114
  - test/dummy/script/rails
115
115
  - test/limited_sessions_test.rb
116
116
  - test/test_helper.rb
117
- homepage: http://iprog.com/projects#limited_sessions
117
+ homepage: https://iprog.com/projects#limited_sessions
118
118
  licenses: []
119
119
  metadata: {}
120
120
  post_install_message:
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.4.8
136
+ rubygems_version: 2.6.12
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Server-side session expiry via either Rack Middleware or ActiveRecord extension