limited_sessions 4.1.0 → 4.2.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 +4 -4
- data/CHANGELOG +6 -0
- data/README +14 -11
- data/lib/limited_sessions/expiry.rb +3 -3
- data/lib/limited_sessions/self_cleaning_session.rb +6 -4
- data/lib/limited_sessions/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72435a434d8e6fb836b3aa85fb4d53d5e09032ad
|
4
|
+
data.tar.gz: 8344fca106d43399d81d71aeb30d2b1fbf4c450a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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-
|
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.
|
14
|
-
|
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
|
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
|
-
|
29
|
-
|
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.
|
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;
|
229
|
-
|
232
|
+
--t (tm@iprog.com; https://iprog.com/)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# LimitedSessions
|
2
|
-
# (c) 2007-
|
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-
|
6
|
-
# Correspondingly, it is compatible with Rails 3.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-
|
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
|
-
|
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
|
-
|
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
|
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.
|
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:
|
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.
|
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.
|
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:
|
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.
|
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
|