auto-session-timeout 0.5 → 0.7
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 +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/{README → README.md} +52 -54
- data/Rakefile +3 -2
- data/auto-session-timeout.gemspec +25 -0
- data/lib/auto/session/timeout.rb +9 -0
- data/lib/auto/session/timeout/version.rb +7 -0
- data/test/auto_session_timeout_test.rb +3 -3
- data/test/test_helper.rb +1 -1
- metadata +95 -44
- data/MIT-LICENSE +0 -16
- data/auto_session_timeout.gemspec +0 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 02bbfdce7a19e58350dc5d7153a95a2673e2f166
|
4
|
+
data.tar.gz: 331e66cc1b92b7415dea5919c67f0003158f9af6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3408a75e3f956e720a70230bf29b9a4cddd06216f2002cb3c997449b55e6fb1a16ad658060c71a7eae9bf5bc005fbdd1fc6e309188dd5876013e7e784abc806
|
7
|
+
data.tar.gz: 99af47d54bf36126b672ba7622599f24a4e0e13cf012d0948dbf2fd4ee1e549db9fbcc299106f7d238b57f066445640fad52f6fb3bdac8f97a4ebd6739f149d1
|
data/.gitignore
ADDED
data/CHANGELOG
CHANGED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Matthew Bass (http://www.matthewbass.com)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README → README.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# auto-session-timeout
|
2
2
|
|
3
3
|
Provides automatic session timeout in a Rails application. Very easy
|
4
4
|
to install and configure. Have you ever wanted to force your users
|
@@ -6,102 +6,100 @@ off your app if they go idle for a certain period of time? Many
|
|
6
6
|
online banking sites use this technique. If your app is used on any
|
7
7
|
kind of public computer system, this plugin is a necessity.
|
8
8
|
|
9
|
+
## Installation
|
9
10
|
|
10
|
-
|
11
|
+
Add this line to your application's Gemfile:
|
11
12
|
|
12
|
-
|
13
|
+
gem 'auto-session-timeout'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
Or install the gem in your Rails project:
|
17
|
-
|
18
|
-
script/plugin install git://github.com/pelargir/auto-session-timeout.git
|
15
|
+
And then execute:
|
19
16
|
|
20
|
-
|
17
|
+
$ bundle
|
21
18
|
|
22
|
-
|
19
|
+
Or install it yourself as:
|
23
20
|
|
21
|
+
$ gem install auto-session-timeout
|
24
22
|
|
25
|
-
|
23
|
+
## Usage
|
26
24
|
|
27
25
|
After installing, tell your application controller to use auto timeout:
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
class ApplicationController < ActionController::Base
|
28
|
+
auto_session_timeout 1.hour
|
29
|
+
...
|
30
|
+
end
|
33
31
|
|
34
|
-
You will also need to insert this line inside the
|
35
|
-
|
32
|
+
You will also need to insert this line inside the body tags in your
|
33
|
+
views. The easiest way to do this is to insert it once inside your
|
36
34
|
default or application-wide layout. Make sure you are only rendering
|
37
35
|
it if the user is logged in, otherwise the plugin will attempt to force
|
38
36
|
non-existent sessions to timeout, wreaking havoc:
|
39
37
|
|
40
|
-
<html>
|
41
|
-
<head>...</head>
|
42
38
|
<body>
|
43
39
|
<% if logged_in? -%>
|
44
40
|
<%= auto_session_timeout_js %>
|
45
41
|
<% end -%>
|
46
|
-
...
|
47
42
|
</body>
|
48
|
-
</html>
|
49
43
|
|
50
44
|
You need to setup two actions: one to return the session status and
|
51
45
|
another that runs when the session times out. You can use the default
|
52
46
|
actions included with the plugin by inserting this line in your target
|
53
47
|
controller (most likely your user or session controller):
|
54
48
|
|
55
|
-
class SessionsController < ApplicationController
|
56
|
-
|
57
|
-
|
58
|
-
end
|
49
|
+
class SessionsController < ApplicationController
|
50
|
+
auto_session_timeout_actions
|
51
|
+
end
|
59
52
|
|
60
53
|
To customize the default actions, simply override them. You can call
|
61
54
|
the render_session_status and render_session_timeout methods to use
|
62
55
|
the default implementation from the plugin, or you can define the
|
63
56
|
actions entirely with your own custom code:
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
58
|
+
class SessionsController < ApplicationController
|
59
|
+
def active
|
60
|
+
render_session_status
|
61
|
+
end
|
62
|
+
|
63
|
+
def timeout
|
64
|
+
render_session_timeout
|
65
|
+
end
|
68
66
|
end
|
69
|
-
|
70
|
-
def timeout
|
71
|
-
render_session_timeout
|
72
|
-
end
|
73
|
-
...
|
74
|
-
end
|
75
67
|
|
76
68
|
In any of these cases, make sure to properly map the actions in
|
77
69
|
your routes.rb file:
|
78
70
|
|
79
|
-
|
80
|
-
|
71
|
+
map.active '/active', :controller => 'sessions', :action => 'active'
|
72
|
+
map.timeout '/timeout', :controller => 'sessions', :action => 'timeout'
|
81
73
|
|
82
74
|
You're done! Enjoy watching your sessions automatically timeout.
|
83
75
|
|
84
|
-
|
85
|
-
== Additional Configuration
|
76
|
+
## Additional Configuration
|
86
77
|
|
87
78
|
By default, the JavaScript code checks the server every 60 seconds for
|
88
79
|
active sessions. If you prefer that it check more frequently, pass a
|
89
80
|
frequency attribute to the helper method. The frequency is given in
|
90
81
|
seconds. The following example checks the server every 15 seconds:
|
91
82
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
83
|
+
<html>
|
84
|
+
<head>...</head>
|
85
|
+
<body>
|
86
|
+
<% if logged_in? -%>
|
87
|
+
<%= auto_session_timeout_js :frequency => 15 %>
|
88
|
+
<% end -%>
|
89
|
+
...
|
90
|
+
</body>
|
91
|
+
</html>
|
92
|
+
|
93
|
+
## Contributing
|
94
|
+
|
95
|
+
1. Fork it
|
96
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
97
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
98
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
99
|
+
5. Create new Pull Request
|
100
|
+
|
101
|
+
## Resources
|
102
|
+
|
103
|
+
* Repository: http://github.com/pelargir/auto-session-timeout/
|
104
|
+
* Blog: http://www.matthewbass.com
|
105
|
+
* Author: Matthew Bass
|
data/Rakefile
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'auto/session/timeout/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "auto-session-timeout"
|
8
|
+
spec.version = Auto::Session::Timeout::VERSION
|
9
|
+
spec.authors = ["Matthew Bass"]
|
10
|
+
spec.email = ["pelargir@gmail.com"]
|
11
|
+
spec.description = %q{Provides automatic session timeout in a Rails application.}
|
12
|
+
spec.summary = %q{Provides automatic session timeout in a Rails application.}
|
13
|
+
spec.homepage = "http://github.com/pelargir/auto-session-timeout"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest", "~> 4.2"
|
24
|
+
spec.add_development_dependency "actionpack", "~> 3.2"
|
25
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,65 +1,116 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto-session-timeout
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.7'
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Matthew Bass
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
date: 2013-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: actionpack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
description: Provides automatic session timeout in a Rails application.
|
70
|
+
email:
|
71
|
+
- pelargir@gmail.com
|
18
72
|
executables: []
|
19
|
-
|
20
73
|
extensions: []
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
files:
|
25
|
-
- auto_session_timeout.gemspec
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
26
77
|
- CHANGELOG
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- auto-session-timeout.gemspec
|
27
83
|
- init.rb
|
84
|
+
- lib/auto/session/timeout.rb
|
85
|
+
- lib/auto/session/timeout/version.rb
|
28
86
|
- lib/auto_session_timeout.rb
|
29
87
|
- lib/auto_session_timeout_helper.rb
|
30
|
-
- MIT-LICENSE
|
31
|
-
- Rakefile
|
32
|
-
- README
|
33
88
|
- test/auto_session_timeout_test.rb
|
34
89
|
- test/test_helper.rb
|
35
|
-
has_rdoc: true
|
36
90
|
homepage: http://github.com/pelargir/auto-session-timeout
|
37
|
-
licenses:
|
38
|
-
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
39
94
|
post_install_message:
|
40
|
-
rdoc_options:
|
41
|
-
|
42
|
-
- README
|
43
|
-
require_paths:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
44
97
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- -
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
version: "0"
|
56
|
-
version:
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
57
108
|
requirements: []
|
58
|
-
|
59
109
|
rubyforge_project:
|
60
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.0.3
|
61
111
|
signing_key:
|
62
|
-
specification_version:
|
112
|
+
specification_version: 4
|
63
113
|
summary: Provides automatic session timeout in a Rails application.
|
64
|
-
test_files:
|
65
|
-
|
114
|
+
test_files:
|
115
|
+
- test/auto_session_timeout_test.rb
|
116
|
+
- test/test_helper.rb
|
data/MIT-LICENSE
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Matthew Bass (http://matthewbass.com)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
4
|
-
and associated documentation files (the "Software"), to deal in the Software without
|
5
|
-
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
6
|
-
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
-
Software is furnished to do so, subject to the following conditions:
|
8
|
-
|
9
|
-
The above copyright notice and this permission notice shall be included in all copies or
|
10
|
-
substantial portions of the Software.
|
11
|
-
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
13
|
-
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
14
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
15
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
16
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,25 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "auto-session-timeout"
|
3
|
-
s.version = "0.5"
|
4
|
-
s.date = "2009-04-22"
|
5
|
-
s.summary = "Provides automatic session timeout in a Rails application."
|
6
|
-
s.email = "pelargir@gmail.com"
|
7
|
-
s.homepage = "http://github.com/pelargir/auto-session-timeout"
|
8
|
-
s.description = "Adds several handy expectations for testing ActiveRecord model validations."
|
9
|
-
s.has_rdoc = true
|
10
|
-
s.authors = ["Matthew Bass"]
|
11
|
-
s.files = [
|
12
|
-
"auto_session_timeout.gemspec",
|
13
|
-
"CHANGELOG",
|
14
|
-
"init.rb",
|
15
|
-
"lib/auto_session_timeout.rb",
|
16
|
-
"lib/auto_session_timeout_helper.rb",
|
17
|
-
"MIT-LICENSE",
|
18
|
-
"Rakefile",
|
19
|
-
"README",
|
20
|
-
"test/auto_session_timeout_test.rb",
|
21
|
-
"test/test_helper.rb"
|
22
|
-
]
|
23
|
-
s.rdoc_options = ["--main", "README"]
|
24
|
-
s.extra_rdoc_files = ["README"]
|
25
|
-
end
|