authlogic 2.1.6 → 2.1.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of authlogic might be problematic. Click here for more details.
- data/VERSION.yml +2 -2
- data/authlogic.gemspec +1 -1
- data/lib/authlogic/session/cookies.rb +67 -15
- data/test/session_test/active_record_trickery_test.rb +6 -6
- metadata +36 -52
data/VERSION.yml
CHANGED
data/authlogic.gemspec
CHANGED
@@ -11,7 +11,7 @@ module Authlogic
|
|
11
11
|
after_destroy :destroy_cookie
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# Configuration for the cookie feature set.
|
16
16
|
module Config
|
17
17
|
# The name of the cookie or the key in the cookies hash. Be sure and use a unique name. If you have multiple sessions and they use the same cookie it will cause problems.
|
@@ -19,7 +19,7 @@ module Authlogic
|
|
19
19
|
#
|
20
20
|
# session = UserSession.new
|
21
21
|
# session.cookie_key => "user_credentials"
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# session = UserSession.new(:super_high_secret)
|
24
24
|
# session.cookie_key => "super_high_secret_user_credentials"
|
25
25
|
#
|
@@ -29,7 +29,7 @@ module Authlogic
|
|
29
29
|
rw_config(:cookie_key, value, "#{guessed_klass_name.underscore}_credentials")
|
30
30
|
end
|
31
31
|
alias_method :cookie_key=, :cookie_key
|
32
|
-
|
32
|
+
|
33
33
|
# If sessions should be remembered by default or not.
|
34
34
|
#
|
35
35
|
# * <tt>Default:</tt> false
|
@@ -38,7 +38,7 @@ module Authlogic
|
|
38
38
|
rw_config(:remember_me, value, false)
|
39
39
|
end
|
40
40
|
alias_method :remember_me=, :remember_me
|
41
|
-
|
41
|
+
|
42
42
|
# The length of time until the cookie expires.
|
43
43
|
#
|
44
44
|
# * <tt>Default:</tt> 3.months
|
@@ -47,8 +47,26 @@ module Authlogic
|
|
47
47
|
rw_config(:remember_me_for, value, 3.months, :_read)
|
48
48
|
end
|
49
49
|
alias_method :remember_me_for=, :remember_me_for
|
50
|
+
|
51
|
+
# Should the cookie be set as secure? If true, the cookie will only be sent over SSL connections
|
52
|
+
#
|
53
|
+
# * <tt>Default:</tt> false
|
54
|
+
# * <tt>Accepts:</tt> Boolean
|
55
|
+
def secure(value = nil)
|
56
|
+
rw_config(:secure, value, false)
|
57
|
+
end
|
58
|
+
alias_method :secure=, :secure
|
59
|
+
|
60
|
+
# Should the cookie be set as httponly? If true, the cookie will not be accessable from javascript
|
61
|
+
#
|
62
|
+
# * <tt>Default:</tt> false
|
63
|
+
# * <tt>Accepts:</tt> Boolean
|
64
|
+
def httponly(value = nil)
|
65
|
+
rw_config(:httponly, value, false)
|
66
|
+
end
|
67
|
+
alias_method :httponly=, :httponly
|
50
68
|
end
|
51
|
-
|
69
|
+
|
52
70
|
# The methods available for an Authlogic::Session::Base object that make up the cookie feature set.
|
53
71
|
module InstanceMethods
|
54
72
|
# Allows you to set the remember_me option when passing credentials.
|
@@ -63,44 +81,76 @@ module Authlogic
|
|
63
81
|
self.remember_me = r if !r.nil?
|
64
82
|
end
|
65
83
|
end
|
66
|
-
|
84
|
+
|
67
85
|
# Is the cookie going to expire after the session is over, or will it stick around?
|
68
86
|
def remember_me
|
69
87
|
return @remember_me if defined?(@remember_me)
|
70
88
|
@remember_me = self.class.remember_me
|
71
89
|
end
|
72
|
-
|
90
|
+
|
73
91
|
# Accepts a boolean as a flag to remember the session or not. Basically to expire the cookie at the end of the session or keep it for "remember_me_until".
|
74
92
|
def remember_me=(value)
|
75
93
|
@remember_me = value
|
76
94
|
end
|
77
|
-
|
95
|
+
|
78
96
|
# See remember_me
|
79
97
|
def remember_me?
|
80
98
|
remember_me == true || remember_me == "true" || remember_me == "1"
|
81
99
|
end
|
82
|
-
|
100
|
+
|
83
101
|
# How long to remember the user if remember_me is true. This is based on the class level configuration: remember_me_for
|
84
102
|
def remember_me_for
|
85
103
|
return unless remember_me?
|
86
104
|
self.class.remember_me_for
|
87
105
|
end
|
88
|
-
|
106
|
+
|
89
107
|
# When to expire the cookie. See remember_me_for configuration option to change this.
|
90
108
|
def remember_me_until
|
91
109
|
return unless remember_me?
|
92
110
|
remember_me_for.from_now
|
93
111
|
end
|
94
|
-
|
112
|
+
|
113
|
+
# If the cookie should be marked as secure (SSL only)
|
114
|
+
def secure
|
115
|
+
return @secure if defined?(@secure)
|
116
|
+
@secure = self.class.secure
|
117
|
+
end
|
118
|
+
|
119
|
+
# Accepts a boolean as to whether the cookie should be marked as secure. If true the cookie will only ever be sent over an SSL connection.
|
120
|
+
def secure=(value)
|
121
|
+
@secure = value
|
122
|
+
end
|
123
|
+
|
124
|
+
# See secure
|
125
|
+
def secure?
|
126
|
+
secure == true || secure == "true" || secure == "1"
|
127
|
+
end
|
128
|
+
|
129
|
+
# If the cookie should be marked as httponly (not accessable via javascript)
|
130
|
+
def httponly
|
131
|
+
return @httponly if defined?(@httponly)
|
132
|
+
@httponly = self.class.httponly
|
133
|
+
end
|
134
|
+
|
135
|
+
# Accepts a boolean as to whether the cookie should be marked as httponly. If true, the cookie will not be accessable from javascript
|
136
|
+
def httponly=(value)
|
137
|
+
@httponly = value
|
138
|
+
end
|
139
|
+
|
140
|
+
# See httponly
|
141
|
+
def httponly?
|
142
|
+
httponly == true || httponly == "true" || httponly == "1"
|
143
|
+
end
|
144
|
+
|
95
145
|
private
|
96
146
|
def cookie_key
|
97
147
|
build_key(self.class.cookie_key)
|
98
148
|
end
|
99
|
-
|
149
|
+
|
100
150
|
def cookie_credentials
|
101
151
|
controller.cookies[cookie_key] && controller.cookies[cookie_key].split("::")
|
102
152
|
end
|
103
|
-
|
153
|
+
|
104
154
|
# Tries to validate the session from information in the cookie
|
105
155
|
def persist_by_cookie
|
106
156
|
persistence_token, record_id = cookie_credentials
|
@@ -112,15 +162,17 @@ module Authlogic
|
|
112
162
|
false
|
113
163
|
end
|
114
164
|
end
|
115
|
-
|
165
|
+
|
116
166
|
def save_cookie
|
117
167
|
controller.cookies[cookie_key] = {
|
118
168
|
:value => "#{record.persistence_token}::#{record.send(record.class.primary_key)}",
|
119
169
|
:expires => remember_me_until,
|
170
|
+
:secure => secure,
|
171
|
+
:http_only => httponly,
|
120
172
|
:domain => controller.cookie_domain
|
121
173
|
}
|
122
174
|
end
|
123
|
-
|
175
|
+
|
124
176
|
def destroy_cookie
|
125
177
|
controller.cookies.delete cookie_key, :domain => controller.cookie_domain
|
126
178
|
end
|
@@ -7,29 +7,29 @@ module SessionTest
|
|
7
7
|
assert_equal "Some attribute", UserSession.human_attribute_name("some_attribute")
|
8
8
|
assert_equal "Some attribute", UserSession.human_attribute_name(:some_attribute)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_human_name
|
12
12
|
assert_equal "Usersession", UserSession.human_name
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_self_and_descendents_from_active_record
|
16
16
|
assert_equal [UserSession], UserSession.self_and_descendents_from_active_record
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_self_and_descendants_from_active_record
|
20
20
|
assert_equal [UserSession], UserSession.self_and_descendants_from_active_record
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
class InstanceMethodsTest < ActiveSupport::TestCase
|
25
25
|
def test_new_record
|
26
26
|
session = UserSession.new
|
27
27
|
assert session.new_record?
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def test_to_model
|
31
31
|
session = UserSession.new
|
32
|
-
|
32
|
+
assert_equal session, session.to_model
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,47 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
- 6
|
10
|
-
version: 2.1.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.7
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ben Johnson of Binary Logic
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2010-08-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activesupport
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
35
30
|
description:
|
36
31
|
email: bjohnson@binarylogic.com
|
37
32
|
executables: []
|
38
|
-
|
39
33
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
42
35
|
- LICENSE
|
43
36
|
- README.rdoc
|
44
|
-
files:
|
37
|
+
files:
|
45
38
|
- .gitignore
|
46
39
|
- CHANGELOG.rdoc
|
47
40
|
- LICENSE
|
@@ -167,41 +160,32 @@ files:
|
|
167
160
|
- test/session_test/unauthorized_record_test.rb
|
168
161
|
- test/session_test/validation_test.rb
|
169
162
|
- test/test_helper.rb
|
170
|
-
has_rdoc: true
|
171
163
|
homepage: http://github.com/binarylogic/authlogic
|
172
164
|
licenses: []
|
173
|
-
|
174
165
|
post_install_message:
|
175
|
-
rdoc_options:
|
166
|
+
rdoc_options:
|
176
167
|
- --charset=UTF-8
|
177
|
-
require_paths:
|
168
|
+
require_paths:
|
178
169
|
- lib
|
179
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
180
171
|
none: false
|
181
|
-
requirements:
|
182
|
-
- -
|
183
|
-
- !ruby/object:Gem::Version
|
184
|
-
|
185
|
-
|
186
|
-
- 0
|
187
|
-
version: "0"
|
188
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
177
|
none: false
|
190
|
-
requirements:
|
191
|
-
- -
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
|
194
|
-
segments:
|
195
|
-
- 0
|
196
|
-
version: "0"
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
197
182
|
requirements: []
|
198
|
-
|
199
183
|
rubyforge_project:
|
200
|
-
rubygems_version: 1.
|
184
|
+
rubygems_version: 1.8.24
|
201
185
|
signing_key:
|
202
186
|
specification_version: 3
|
203
187
|
summary: A clean, simple, and unobtrusive ruby authentication solution.
|
204
|
-
test_files:
|
188
|
+
test_files:
|
205
189
|
- test/acts_as_authentic_test/base_test.rb
|
206
190
|
- test/acts_as_authentic_test/email_test.rb
|
207
191
|
- test/acts_as_authentic_test/logged_in_status_test.rb
|