authlogic 1.2.0 → 1.2.1

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.

Files changed (34) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/Manifest +4 -4
  3. data/README.rdoc +49 -20
  4. data/Rakefile +0 -1
  5. data/authlogic.gemspec +9 -7
  6. data/lib/authlogic.rb +3 -3
  7. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/config.rb +35 -17
  8. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/credentials.rb +21 -17
  9. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/perishability.rb +75 -0
  10. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/persistence.rb +7 -7
  11. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/session_maintenance.rb +1 -1
  12. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/single_access.rb +2 -2
  13. data/lib/authlogic/session/authenticates_many_association.rb +1 -0
  14. data/lib/authlogic/session/config.rb +4 -4
  15. data/lib/authlogic/session/cookies.rb +2 -2
  16. data/lib/authlogic/session/params.rb +2 -2
  17. data/lib/authlogic/session/perishability.rb +18 -0
  18. data/lib/authlogic/session/session.rb +2 -2
  19. data/lib/authlogic/version.rb +1 -1
  20. data/test/fixtures/employees.yml +2 -2
  21. data/test/fixtures/users.yml +3 -3
  22. data/test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/config_test.rb +8 -4
  23. data/test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/credentials_test.rb +5 -5
  24. data/test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb +41 -0
  25. data/test/session_tests/authenticates_many_association_test.rb +8 -0
  26. data/test/session_tests/base_test.rb +4 -4
  27. data/test/session_tests/cookies_test.rb +1 -1
  28. data/test/session_tests/{password_reset_test.rb → perishability_test.rb} +3 -3
  29. data/test/session_tests/session_test.rb +4 -4
  30. data/test/test_helper.rb +5 -5
  31. metadata +11 -11
  32. data/lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/password_reset.rb +0 -73
  33. data/lib/authlogic/session/password_reset.rb +0 -17
  34. data/test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/password_reset_test.rb +0 -40
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: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-16 00:00:00 -05:00
12
+ date: 2008-11-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ extra_rdoc_files:
48
48
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/config.rb
49
49
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/credentials.rb
50
50
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/logged_in.rb
51
- - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/password_reset.rb
51
+ - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/perishability.rb
52
52
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/persistence.rb
53
53
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/session_maintenance.rb
54
54
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/single_access.rb
@@ -62,7 +62,7 @@ extra_rdoc_files:
62
62
  - lib/authlogic/session/cookies.rb
63
63
  - lib/authlogic/session/errors.rb
64
64
  - lib/authlogic/session/params.rb
65
- - lib/authlogic/session/password_reset.rb
65
+ - lib/authlogic/session/perishability.rb
66
66
  - lib/authlogic/session/scopes.rb
67
67
  - lib/authlogic/session/session.rb
68
68
  - lib/authlogic/version.rb
@@ -79,7 +79,7 @@ files:
79
79
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/config.rb
80
80
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/credentials.rb
81
81
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/logged_in.rb
82
- - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/password_reset.rb
82
+ - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/perishability.rb
83
83
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/persistence.rb
84
84
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/session_maintenance.rb
85
85
  - lib/authlogic/orm_adapters/active_record_adapter/acts_as_authentic/single_access.rb
@@ -93,7 +93,7 @@ files:
93
93
  - lib/authlogic/session/cookies.rb
94
94
  - lib/authlogic/session/errors.rb
95
95
  - lib/authlogic/session/params.rb
96
- - lib/authlogic/session/password_reset.rb
96
+ - lib/authlogic/session/perishability.rb
97
97
  - lib/authlogic/session/scopes.rb
98
98
  - lib/authlogic/session/session.rb
99
99
  - lib/authlogic/version.rb
@@ -115,7 +115,7 @@ files:
115
115
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/config_test.rb
116
116
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/credentials_test.rb
117
117
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/logged_in_test.rb
118
- - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/password_reset_test.rb
118
+ - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
119
119
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
120
120
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/session_maintenance_test.rb
121
121
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/single_access_test.rb
@@ -126,7 +126,7 @@ files:
126
126
  - test/session_tests/config_test.rb
127
127
  - test/session_tests/cookies_test.rb
128
128
  - test/session_tests/params_test.rb
129
- - test/session_tests/password_reset_test.rb
129
+ - test/session_tests/perishability_test.rb
130
130
  - test/session_tests/scopes_test.rb
131
131
  - test/session_tests/session_test.rb
132
132
  - test/test_helper.rb
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  requirements: []
159
159
 
160
160
  rubyforge_project: authlogic
161
- rubygems_version: 1.2.0
161
+ rubygems_version: 1.3.1
162
162
  signing_key:
163
163
  specification_version: 2
164
164
  summary: A clean, simple, and unobtrusive ruby authentication solution.
@@ -166,7 +166,7 @@ test_files:
166
166
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/config_test.rb
167
167
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/credentials_test.rb
168
168
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/logged_in_test.rb
169
- - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/password_reset_test.rb
169
+ - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
170
170
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
171
171
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/session_maintenance_test.rb
172
172
  - test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/single_access_test.rb
@@ -177,7 +177,7 @@ test_files:
177
177
  - test/session_tests/config_test.rb
178
178
  - test/session_tests/cookies_test.rb
179
179
  - test/session_tests/params_test.rb
180
- - test/session_tests/password_reset_test.rb
180
+ - test/session_tests/perishability_test.rb
181
181
  - test/session_tests/scopes_test.rb
182
182
  - test/session_tests/session_test.rb
183
183
  - test/test_helper.rb
@@ -1,73 +0,0 @@
1
- module Authlogic
2
- module ORMAdapters
3
- module ActiveRecordAdapter
4
- module ActsAsAuthentic
5
- # = Password Reset
6
- #
7
- # Handles all logic the deals with maintaining the password reset token. This token should be used to authenticate a user that is not logged in so that they
8
- # can change their password.
9
- #
10
- # === Class Methods
11
- #
12
- # * <tt>find_using_{options[:password_reset_token_field]}(token)</tt> - returns the record that matches the pased token. The record's updated at column must not be older than
13
- # {options[:password_reset_token_valid_for]} ago. Lastly, if a blank token is passed no record will be returned.
14
- #
15
- # === Instance Methods
16
- #
17
- # * <tt>reset_#{options[:password_reset_token_field]}</tt> - resets the password reset token field to a friendly unique token.
18
- # * <tt>reset_#{options[:password_reset_token_field]}!</tt> - same as above but saves the record afterwards.
19
- module PasswordReset
20
- def acts_as_authentic_with_password_reset(options = {})
21
- acts_as_authentic_without_password_reset(options)
22
-
23
- return if options[:password_reset_token_field].blank?
24
-
25
- class_eval <<-"end_eval", __FILE__, __LINE__
26
- validates_uniqueness_of :#{options[:password_reset_token_field]}
27
-
28
- before_validation :reset_#{options[:password_reset_token_field]}, :unless => :resetting_#{options[:password_reset_token_field]}?
29
-
30
- def self.find_using_#{options[:password_reset_token_field]}(token)
31
- return if token.blank?
32
-
33
- conditions_sql = "#{options[:password_reset_token_field]} = ?"
34
- conditions_subs = [token]
35
-
36
- if column_names.include?("updated_at") && #{options[:password_reset_token_valid_for]} > 0
37
- conditions_sql += " and updated_at > ?"
38
- conditions_subs << #{options[:password_reset_token_valid_for]}.seconds.ago
39
- end
40
-
41
- find(:first, :conditions => [conditions_sql, *conditions_subs])
42
- end
43
-
44
- def reset_#{options[:password_reset_token_field]}
45
- self.#{options[:password_reset_token_field]} = self.class.friendly_unique_token
46
- end
47
-
48
- def reset_#{options[:password_reset_token_field]}!
49
- reset_#{options[:password_reset_token_field]}
50
- @resetting_#{options[:password_reset_token_field]} = true
51
- result = save_without_session_maintenance
52
- @resetting_#{options[:password_reset_token_field]} = false
53
- result
54
- end
55
-
56
- private
57
- def resetting_#{options[:password_reset_token_field]}?
58
- @resetting_#{options[:password_reset_token_field]} == true
59
- end
60
- end_eval
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
67
-
68
- ActiveRecord::Base.class_eval do
69
- class << self
70
- include Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::PasswordReset
71
- alias_method_chain :acts_as_authentic, :password_reset
72
- end
73
- end
@@ -1,17 +0,0 @@
1
- module Authlogic
2
- module Session
3
- # = Password Reset
4
- #
5
- # Provides utilities that assist in maintaining the password reset token. This module just resets the token after a session has been saved, just to keep changing it and add extra security.
6
- module PasswordReset
7
- def self.included(klass)
8
- klass.after_save :reset_password_reset_token!
9
- end
10
-
11
- private
12
- def reset_password_reset_token!
13
- record.send("reset_#{password_reset_token_field}!") if record.respond_to?("reset_#{password_reset_token_field}!")
14
- end
15
- end
16
- end
17
- end
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../test_helper.rb'
2
-
3
- module ORMAdaptersTests
4
- module ActiveRecordAdapterTests
5
- module ActsAsAuthenticTests
6
- class PasswordResetTest < ActiveSupport::TestCase
7
- def test_before_validation
8
- ben = users(:ben)
9
- old_password_reset_token = ben.password_reset_token
10
- assert ben.valid?
11
- assert_not_equal old_password_reset_token, ben.password_reset_token
12
- ben.reload
13
- assert_equal old_password_reset_token, ben.password_reset_token
14
- assert ben.save
15
- assert_not_equal old_password_reset_token, ben.password_reset_token
16
- end
17
-
18
- def test_find_using_password_reset_token
19
- ben = users(:ben)
20
- assert_nil User.find_using_password_reset_token("")
21
- assert_equal ben, User.find_using_password_reset_token(ben.password_reset_token)
22
- assert ben.class.connection.execute("update users set updated_at = '#{10.minutes.ago.to_s(:db)}' where id = '#{ben.id}';")
23
- assert_nil User.find_using_password_reset_token(ben.password_reset_token)
24
- end
25
-
26
- def test_reset_password_reset_token
27
- ben = users(:ben)
28
- old_password_reset_token = ben.password_reset_token
29
- ben.reset_password_reset_token
30
- assert_not_equal old_password_reset_token, ben.password_reset_token
31
- ben.reload
32
- assert_equal old_password_reset_token, ben.password_reset_token
33
- ben.reset_password_reset_token!
34
- ben.reload
35
- assert_not_equal old_password_reset_token, ben.password_reset_token
36
- end
37
- end
38
- end
39
- end
40
- end