authlogic 4.1.0 → 4.1.1
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/.gitignore +1 -0
- data/.rubocop.yml +0 -4
- data/.rubocop_todo.yml +32 -33
- data/CHANGELOG.md +15 -0
- data/Rakefile +2 -4
- data/authlogic.gemspec +2 -1
- data/lib/authlogic/acts_as_authentic/base.rb +13 -13
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -3
- data/lib/authlogic/acts_as_authentic/login.rb +4 -4
- data/lib/authlogic/acts_as_authentic/password.rb +99 -98
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +3 -3
- data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +32 -32
- data/lib/authlogic/acts_as_authentic/restful_authentication.rb +14 -14
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +60 -60
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +6 -6
- data/lib/authlogic/authenticates_many/association.rb +3 -3
- data/lib/authlogic/config.rb +9 -9
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +28 -8
- data/lib/authlogic/controller_adapters/rails_adapter.rb +3 -3
- data/lib/authlogic/crypto_providers/aes256.rb +20 -20
- data/lib/authlogic/crypto_providers/bcrypt.rb +8 -8
- data/lib/authlogic/crypto_providers/scrypt.rb +8 -8
- data/lib/authlogic/session/activation.rb +3 -3
- data/lib/authlogic/session/brute_force_protection.rb +32 -32
- data/lib/authlogic/session/callbacks.rb +49 -35
- data/lib/authlogic/session/cookies.rb +58 -49
- data/lib/authlogic/session/foundation.rb +3 -3
- data/lib/authlogic/session/id.rb +9 -4
- data/lib/authlogic/session/klass.rb +6 -6
- data/lib/authlogic/session/magic_columns.rb +5 -17
- data/lib/authlogic/session/params.rb +3 -0
- data/lib/authlogic/session/password.rb +105 -104
- data/lib/authlogic/session/perishable_token.rb +5 -5
- data/lib/authlogic/session/persistence.rb +5 -4
- data/lib/authlogic/session/priority_record.rb +8 -8
- data/lib/authlogic/session/scopes.rb +23 -23
- data/lib/authlogic/session/timeout.rb +11 -11
- data/lib/authlogic/session/unauthorized_record.rb +6 -6
- data/lib/authlogic/session/validation.rb +9 -9
- data/lib/authlogic/test_case.rb +5 -0
- data/lib/authlogic/test_case/mock_request.rb +2 -2
- data/lib/authlogic/version.rb +4 -3
- data/test/acts_as_authentic_test/password_test.rb +23 -23
- data/test/test_helper.rb +96 -93
- metadata +18 -4
data/lib/authlogic/test_case.rb
CHANGED
@@ -175,6 +175,11 @@ module Authlogic
|
|
175
175
|
# assert_logged_in
|
176
176
|
# end
|
177
177
|
module TestCase
|
178
|
+
def initialize(*args)
|
179
|
+
@request = nil
|
180
|
+
super
|
181
|
+
end
|
182
|
+
|
178
183
|
# Activates authlogic so that you can use it in your tests. You should call
|
179
184
|
# this method in your test's setup. Ex:
|
180
185
|
#
|
data/lib/authlogic/version.rb
CHANGED
@@ -9,12 +9,13 @@ module Authlogic
|
|
9
9
|
# than a `VERSION` string, because `::Gem::Version` is easier to use in a
|
10
10
|
# comparison.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
# rubygems (currently) needs to be able to modify it.
|
12
|
+
# We cannot return a frozen `Version`, because rubygems will try to modify it.
|
14
13
|
# https://github.com/binarylogic/authlogic/pull/590
|
15
14
|
#
|
15
|
+
# Added in 4.0.0
|
16
|
+
#
|
16
17
|
# @api public
|
17
18
|
def self.gem_version
|
18
|
-
::Gem::Version.new("4.1.
|
19
|
+
::Gem::Version.new("4.1.1")
|
19
20
|
end
|
20
21
|
end
|
@@ -233,29 +233,29 @@ module ActsAsAuthenticTest
|
|
233
233
|
|
234
234
|
private
|
235
235
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
end
|
236
|
+
def transition_password_to(
|
237
|
+
crypto_provider,
|
238
|
+
records,
|
239
|
+
from_crypto_providers = Authlogic::CryptoProviders::Sha512
|
240
|
+
)
|
241
|
+
records = [records] unless records.is_a?(Array)
|
242
|
+
User.acts_as_authentic do |c|
|
243
|
+
c.crypto_provider = crypto_provider
|
244
|
+
c.transition_from_crypto_providers = from_crypto_providers
|
245
|
+
end
|
246
|
+
records.each do |record|
|
247
|
+
old_hash = record.crypted_password
|
248
|
+
old_persistence_token = record.persistence_token
|
249
|
+
assert record.valid_password?(password_for(record))
|
250
|
+
assert_not_equal old_hash.to_s, record.crypted_password.to_s
|
251
|
+
assert_not_equal old_persistence_token.to_s, record.persistence_token.to_s
|
252
|
+
|
253
|
+
old_hash = record.crypted_password
|
254
|
+
old_persistence_token = record.persistence_token
|
255
|
+
assert record.valid_password?(password_for(record))
|
256
|
+
assert_equal old_hash.to_s, record.crypted_password.to_s
|
257
|
+
assert_equal old_persistence_token.to_s, record.persistence_token.to_s
|
259
258
|
end
|
259
|
+
end
|
260
260
|
end
|
261
261
|
end
|
data/test/test_helper.rb
CHANGED
@@ -5,6 +5,9 @@ require "active_record"
|
|
5
5
|
require "active_record/fixtures"
|
6
6
|
require "timecop"
|
7
7
|
require "i18n"
|
8
|
+
require "minitest/reporters"
|
9
|
+
|
10
|
+
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
8
11
|
|
9
12
|
I18n.load_path << File.dirname(__FILE__) + "/i18n/lol.yml"
|
10
13
|
|
@@ -146,116 +149,116 @@ module ActiveSupport
|
|
146
149
|
|
147
150
|
private
|
148
151
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end
|
167
|
-
model.original_acts_as_authentic_config = model.acts_as_authentic_config
|
152
|
+
# Many of the tests change Authlogic config for the test models. Some tests
|
153
|
+
# were not resetting the config after tests, which didn't surface as broken
|
154
|
+
# tests until Rails 4.1 was added for testing. This ensures that all the
|
155
|
+
# models start tests with their original config.
|
156
|
+
def config_setup
|
157
|
+
[
|
158
|
+
Project,
|
159
|
+
Affiliate,
|
160
|
+
Employee,
|
161
|
+
EmployeeSession,
|
162
|
+
Ldaper,
|
163
|
+
User,
|
164
|
+
UserSession,
|
165
|
+
Company
|
166
|
+
].each do |model|
|
167
|
+
unless model.respond_to?(:original_acts_as_authentic_config)
|
168
|
+
model.class_attribute :original_acts_as_authentic_config
|
168
169
|
end
|
170
|
+
model.original_acts_as_authentic_config = model.acts_as_authentic_config
|
169
171
|
end
|
172
|
+
end
|
170
173
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
174
|
+
def config_teardown
|
175
|
+
[
|
176
|
+
Project,
|
177
|
+
Affiliate,
|
178
|
+
Employee,
|
179
|
+
EmployeeSession,
|
180
|
+
Ldaper,
|
181
|
+
User,
|
182
|
+
UserSession,
|
183
|
+
Company
|
184
|
+
].each do |model|
|
185
|
+
model.acts_as_authentic_config = model.original_acts_as_authentic_config
|
184
186
|
end
|
187
|
+
end
|
185
188
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
189
|
+
def password_for(user)
|
190
|
+
case user
|
191
|
+
when users(:ben)
|
192
|
+
"benrocks"
|
193
|
+
when users(:zack)
|
194
|
+
"zackrocks"
|
195
|
+
when users(:aaron)
|
196
|
+
"aaronrocks"
|
195
197
|
end
|
198
|
+
end
|
196
199
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
202
|
-
yield
|
203
|
-
controller.http_user = controller.http_password = controller.realm = nil
|
200
|
+
def http_basic_auth_for(user = nil)
|
201
|
+
unless user.blank?
|
202
|
+
controller.http_user = user.login
|
203
|
+
controller.http_password = password_for(user)
|
204
204
|
end
|
205
|
+
yield
|
206
|
+
controller.http_user = controller.http_password = controller.realm = nil
|
207
|
+
end
|
205
208
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
209
|
+
def set_cookie_for(user)
|
210
|
+
controller.cookies["user_credentials"] = {
|
211
|
+
value: "#{user.persistence_token}::#{user.id}",
|
212
|
+
expires: nil
|
213
|
+
}
|
214
|
+
end
|
212
215
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
+
def unset_cookie
|
217
|
+
controller.cookies["user_credentials"] = nil
|
218
|
+
end
|
216
219
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
+
def set_params_for(user)
|
221
|
+
controller.params["user_credentials"] = user.single_access_token
|
222
|
+
end
|
220
223
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
+
def unset_params
|
225
|
+
controller.params["user_credentials"] = nil
|
226
|
+
end
|
224
227
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
+
def set_request_content_type(type)
|
229
|
+
controller.request_content_type = type
|
230
|
+
end
|
228
231
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
+
def unset_request_content_type
|
233
|
+
controller.request_content_type = nil
|
234
|
+
end
|
232
235
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
end
|
236
|
+
def session_credentials_prefix(scope_record)
|
237
|
+
if scope_record.nil?
|
238
|
+
""
|
239
|
+
else
|
240
|
+
format(
|
241
|
+
"%s_%d_",
|
242
|
+
scope_record.class.model_name.name.underscore,
|
243
|
+
scope_record.id
|
244
|
+
)
|
243
245
|
end
|
246
|
+
end
|
244
247
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
248
|
+
# Sets the session variables that `record` (eg. a `User`) would have after
|
249
|
+
# logging in.
|
250
|
+
#
|
251
|
+
# If `record` belongs to an `authenticates_many` association that uses the
|
252
|
+
# `scope_cookies` option, then a `scope_record` can be provided.
|
253
|
+
def set_session_for(record, scope_record = nil)
|
254
|
+
prefix = session_credentials_prefix(scope_record)
|
255
|
+
record_class_name = record.class.model_name.name.underscore
|
256
|
+
controller.session["#{prefix}#{record_class_name}_credentials"] = record.persistence_token
|
257
|
+
controller.session["#{prefix}#{record_class_name}_credentials_id"] = record.id
|
258
|
+
end
|
256
259
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
+
def unset_session
|
261
|
+
controller.session["user_credentials"] = controller.session["user_credentials_id"] = nil
|
262
|
+
end
|
260
263
|
end
|
261
264
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Johnson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -114,20 +114,34 @@ dependencies:
|
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '10.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: minitest-reporters
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.2'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.2'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: rubocop
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
120
134
|
requirements:
|
121
135
|
- - "~>"
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
137
|
+
version: 0.56.0
|
124
138
|
type: :development
|
125
139
|
prerelease: false
|
126
140
|
version_requirements: !ruby/object:Gem::Requirement
|
127
141
|
requirements:
|
128
142
|
- - "~>"
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.
|
144
|
+
version: 0.56.0
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
146
|
name: timecop
|
133
147
|
requirement: !ruby/object:Gem::Requirement
|