authlogic 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +0 -4
  4. data/.rubocop_todo.yml +32 -33
  5. data/CHANGELOG.md +15 -0
  6. data/Rakefile +2 -4
  7. data/authlogic.gemspec +2 -1
  8. data/lib/authlogic/acts_as_authentic/base.rb +13 -13
  9. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -3
  10. data/lib/authlogic/acts_as_authentic/login.rb +4 -4
  11. data/lib/authlogic/acts_as_authentic/password.rb +99 -98
  12. data/lib/authlogic/acts_as_authentic/persistence_token.rb +3 -3
  13. data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +32 -32
  14. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +14 -14
  15. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +60 -60
  16. data/lib/authlogic/acts_as_authentic/single_access_token.rb +6 -6
  17. data/lib/authlogic/authenticates_many/association.rb +3 -3
  18. data/lib/authlogic/config.rb +9 -9
  19. data/lib/authlogic/controller_adapters/abstract_adapter.rb +28 -8
  20. data/lib/authlogic/controller_adapters/rails_adapter.rb +3 -3
  21. data/lib/authlogic/crypto_providers/aes256.rb +20 -20
  22. data/lib/authlogic/crypto_providers/bcrypt.rb +8 -8
  23. data/lib/authlogic/crypto_providers/scrypt.rb +8 -8
  24. data/lib/authlogic/session/activation.rb +3 -3
  25. data/lib/authlogic/session/brute_force_protection.rb +32 -32
  26. data/lib/authlogic/session/callbacks.rb +49 -35
  27. data/lib/authlogic/session/cookies.rb +58 -49
  28. data/lib/authlogic/session/foundation.rb +3 -3
  29. data/lib/authlogic/session/id.rb +9 -4
  30. data/lib/authlogic/session/klass.rb +6 -6
  31. data/lib/authlogic/session/magic_columns.rb +5 -17
  32. data/lib/authlogic/session/params.rb +3 -0
  33. data/lib/authlogic/session/password.rb +105 -104
  34. data/lib/authlogic/session/perishable_token.rb +5 -5
  35. data/lib/authlogic/session/persistence.rb +5 -4
  36. data/lib/authlogic/session/priority_record.rb +8 -8
  37. data/lib/authlogic/session/scopes.rb +23 -23
  38. data/lib/authlogic/session/timeout.rb +11 -11
  39. data/lib/authlogic/session/unauthorized_record.rb +6 -6
  40. data/lib/authlogic/session/validation.rb +9 -9
  41. data/lib/authlogic/test_case.rb +5 -0
  42. data/lib/authlogic/test_case/mock_request.rb +2 -2
  43. data/lib/authlogic/version.rb +4 -3
  44. data/test/acts_as_authentic_test/password_test.rb +23 -23
  45. data/test/test_helper.rb +96 -93
  46. metadata +18 -4
@@ -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
  #
@@ -17,8 +17,8 @@ module Authlogic
17
17
 
18
18
  private
19
19
 
20
- def method_missing(*args, &block)
21
- end
20
+ def method_missing(*args, &block)
21
+ end
22
22
  end
23
23
  end
24
24
  end
@@ -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
- # Perhaps surprisingly, we cannot return a frozen `Version`, because eg.
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.0")
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
- 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
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
@@ -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
- # Many of the tests change Authlogic config for the test models. Some tests
150
- # were not resetting the config after tests, which didn't surface as broken
151
- # tests until Rails 4.1 was added for testing. This ensures that all the
152
- # models start tests with their original config.
153
- def config_setup
154
- [
155
- Project,
156
- Affiliate,
157
- Employee,
158
- EmployeeSession,
159
- Ldaper,
160
- User,
161
- UserSession,
162
- Company
163
- ].each do |model|
164
- unless model.respond_to?(:original_acts_as_authentic_config)
165
- model.class_attribute :original_acts_as_authentic_config
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
- def config_teardown
172
- [
173
- Project,
174
- Affiliate,
175
- Employee,
176
- EmployeeSession,
177
- Ldaper,
178
- User,
179
- UserSession,
180
- Company
181
- ].each do |model|
182
- model.acts_as_authentic_config = model.original_acts_as_authentic_config
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
- def password_for(user)
187
- case user
188
- when users(:ben)
189
- "benrocks"
190
- when users(:zack)
191
- "zackrocks"
192
- when users(:aaron)
193
- "aaronrocks"
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
- def http_basic_auth_for(user = nil)
198
- unless user.blank?
199
- controller.http_user = user.login
200
- controller.http_password = password_for(user)
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
- def set_cookie_for(user)
207
- controller.cookies["user_credentials"] = {
208
- value: "#{user.persistence_token}::#{user.id}",
209
- expires: nil
210
- }
211
- end
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
- def unset_cookie
214
- controller.cookies["user_credentials"] = nil
215
- end
216
+ def unset_cookie
217
+ controller.cookies["user_credentials"] = nil
218
+ end
216
219
 
217
- def set_params_for(user)
218
- controller.params["user_credentials"] = user.single_access_token
219
- end
220
+ def set_params_for(user)
221
+ controller.params["user_credentials"] = user.single_access_token
222
+ end
220
223
 
221
- def unset_params
222
- controller.params["user_credentials"] = nil
223
- end
224
+ def unset_params
225
+ controller.params["user_credentials"] = nil
226
+ end
224
227
 
225
- def set_request_content_type(type)
226
- controller.request_content_type = type
227
- end
228
+ def set_request_content_type(type)
229
+ controller.request_content_type = type
230
+ end
228
231
 
229
- def unset_request_content_type
230
- controller.request_content_type = nil
231
- end
232
+ def unset_request_content_type
233
+ controller.request_content_type = nil
234
+ end
232
235
 
233
- def session_credentials_prefix(scope_record)
234
- if scope_record.nil?
235
- ""
236
- else
237
- format(
238
- "%s_%d_",
239
- scope_record.class.model_name.name.underscore,
240
- scope_record.id
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
- # Sets the session variables that `record` (eg. a `User`) would have after
246
- # logging in.
247
- #
248
- # If `record` belongs to an `authenticates_many` association that uses the
249
- # `scope_cookies` option, then a `scope_record` can be provided.
250
- def set_session_for(record, scope_record = nil)
251
- prefix = session_credentials_prefix(scope_record)
252
- record_class_name = record.class.model_name.name.underscore
253
- controller.session["#{prefix}#{record_class_name}_credentials"] = record.persistence_token
254
- controller.session["#{prefix}#{record_class_name}_credentials_id"] = record.id
255
- end
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
- def unset_session
258
- controller.session["user_credentials"] = controller.session["user_credentials_id"] = nil
259
- end
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.0
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-04-24 00:00:00.000000000 Z
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.54.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.54.0
144
+ version: 0.56.0
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: timecop
133
147
  requirement: !ruby/object:Gem::Requirement