authlogic 2.0.9 → 2.0.11
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/CHANGELOG.rdoc +18 -1
- data/Manifest.txt +2 -0
- data/README.rdoc +89 -159
- data/lib/authlogic/acts_as_authentic/email.rb +33 -0
- data/lib/authlogic/acts_as_authentic/login.rb +35 -2
- data/lib/authlogic/acts_as_authentic/password.rb +100 -19
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +12 -1
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +1 -1
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +5 -1
- data/lib/authlogic/i18n.rb +1 -1
- data/lib/authlogic/session/http_auth.rb +46 -11
- data/lib/authlogic/session/params.rb +12 -7
- data/lib/authlogic/test_case.rb +42 -20
- data/lib/authlogic/test_case/mock_request.rb +3 -9
- data/lib/authlogic/version.rb +1 -1
- data/shoulda_macros/authlogic.rb +2 -2
- data/test/acts_as_authentic_test/email_test.rb +4 -0
- data/test/acts_as_authentic_test/login_test.rb +5 -1
- data/test/acts_as_authentic_test/password_test.rb +28 -0
- data/test/acts_as_authentic_test/session_maintenance_test.rb +8 -0
- data/test/acts_as_authentic_test/single_access_test.rb +5 -0
- data/test/libs/affiliate.rb +7 -0
- data/test/libs/ldaper.rb +3 -0
- data/test/session_test/http_auth_test.rb +20 -8
- data/test/test_helper.rb +8 -0
- metadata +4 -2
@@ -7,19 +7,13 @@ module Authlogic
|
|
7
7
|
self.controller = controller
|
8
8
|
end
|
9
9
|
|
10
|
-
def request_method
|
11
|
-
nil
|
12
|
-
end
|
13
|
-
|
14
|
-
def referer
|
15
|
-
end
|
16
|
-
|
17
10
|
def remote_ip
|
18
11
|
(controller && controller.respond_to?(:env) && controller.env.is_a?(Hash) && controller.env['REMOTE_ADDR']) || "1.1.1.1"
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
|
-
|
14
|
+
private
|
15
|
+
def method_missiing(*args, &block)
|
16
|
+
end
|
23
17
|
end
|
24
18
|
end
|
25
19
|
end
|
data/lib/authlogic/version.rb
CHANGED
data/shoulda_macros/authlogic.rb
CHANGED
@@ -4,8 +4,8 @@ module Authlogic
|
|
4
4
|
def self.should_be_authentic
|
5
5
|
klass = model_class
|
6
6
|
should "acts as authentic" do
|
7
|
-
assert klass.respond_to?(:password=)
|
8
|
-
assert klass.respond_to?(:valid_password?)
|
7
|
+
assert klass.new.respond_to?(:password=)
|
8
|
+
assert klass.new.respond_to?(:valid_password?)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -33,7 +33,7 @@ module ActsAsAuthenticTest
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_validates_format_of_login_field_options_config
|
36
|
-
default = {:with => /\A\w[\w
|
36
|
+
default = {:with => /\A\w[\w\.+-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
|
37
37
|
assert_equal default, User.validates_format_of_login_field_options
|
38
38
|
assert_equal default, Employee.validates_format_of_login_field_options
|
39
39
|
|
@@ -73,6 +73,10 @@ module ActsAsAuthenticTest
|
|
73
73
|
u.login = "fdsfdsfdsfdsfs"
|
74
74
|
assert !u.valid?
|
75
75
|
assert !u.errors.on(:login)
|
76
|
+
|
77
|
+
u.login = "dakota.dux+1@gmail.com"
|
78
|
+
assert !u.valid?
|
79
|
+
assert !u.errors.on(:login)
|
76
80
|
end
|
77
81
|
|
78
82
|
def test_validates_uniqueness_of_login_field
|
@@ -32,6 +32,14 @@ module ActsAsAuthenticTest
|
|
32
32
|
assert User.ignore_blank_passwords
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_check_passwords_against_database
|
36
|
+
assert User.check_passwords_against_database
|
37
|
+
User.check_passwords_against_database = false
|
38
|
+
assert !User.check_passwords_against_database
|
39
|
+
User.check_passwords_against_database true
|
40
|
+
assert User.check_passwords_against_database
|
41
|
+
end
|
42
|
+
|
35
43
|
def test_validate_password_field_config
|
36
44
|
assert User.validate_password_field
|
37
45
|
assert Employee.validate_password_field
|
@@ -160,6 +168,26 @@ module ActsAsAuthenticTest
|
|
160
168
|
transition_password_to(Authlogic::CryptoProviders::Sha512, ben, [Authlogic::CryptoProviders::Sha1, Authlogic::CryptoProviders::BCrypt])
|
161
169
|
end
|
162
170
|
|
171
|
+
def test_checks_password_against_database
|
172
|
+
ben = users(:ben)
|
173
|
+
ben.password = "new pass"
|
174
|
+
assert !ben.valid_password?("new pass")
|
175
|
+
assert ben.valid_password?("benrocks")
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_checks_password_against_database_and_always_fails_on_new_records
|
179
|
+
user = User.new
|
180
|
+
user.password = "new pass"
|
181
|
+
assert !user.valid_password?("new pass")
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_checks_password_against_object
|
185
|
+
ben = users(:ben)
|
186
|
+
ben.password = "new pass"
|
187
|
+
assert ben.valid_password?("new pass", false)
|
188
|
+
assert !ben.valid_password?("benrocks", false)
|
189
|
+
end
|
190
|
+
|
163
191
|
def test_reset_password
|
164
192
|
ben = users(:ben)
|
165
193
|
old_crypted_password = ben.crypted_password
|
@@ -2,6 +2,14 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
2
2
|
|
3
3
|
module ActsAsAuthenticTest
|
4
4
|
class SessionMaintenanceTest < ActiveSupport::TestCase
|
5
|
+
def test_maintain_sessions_config
|
6
|
+
assert User.maintain_sessions
|
7
|
+
User.maintain_sessions = false
|
8
|
+
assert !User.maintain_sessions
|
9
|
+
User.maintain_sessions true
|
10
|
+
assert User.maintain_sessions
|
11
|
+
end
|
12
|
+
|
5
13
|
def test_login_after_create
|
6
14
|
assert User.create(:login => "awesome", :password => "saweet", :password_confirmation => "saweet", :email => "awesome@awesome.com")
|
7
15
|
assert UserSession.find
|
data/test/libs/ldaper.rb
ADDED
@@ -2,14 +2,26 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
2
2
|
|
3
3
|
module SessionTest
|
4
4
|
class HttpAuthTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
assert_equal
|
12
|
-
|
5
|
+
class ConfiTest < ActiveSupport::TestCase
|
6
|
+
def test_allow_http_basic_auth
|
7
|
+
UserSession.allow_http_basic_auth = false
|
8
|
+
assert_equal false, UserSession.allow_http_basic_auth
|
9
|
+
|
10
|
+
UserSession.allow_http_basic_auth true
|
11
|
+
assert_equal true, UserSession.allow_http_basic_auth
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class InstanceMethodsTest < ActiveSupport::TestCase
|
16
|
+
def test_persist_persist_by_http_auth
|
17
|
+
ben = users(:ben)
|
18
|
+
http_basic_auth_for { assert !UserSession.find }
|
19
|
+
http_basic_auth_for(ben) do
|
20
|
+
assert session = UserSession.find
|
21
|
+
assert_equal ben, session.record
|
22
|
+
assert_equal ben.login, session.login
|
23
|
+
assert_equal "benrocks", session.send(:protected_password)
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
data/test/test_helper.rb
CHANGED
@@ -79,6 +79,13 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
79
79
|
t.string :pw_salt
|
80
80
|
t.string :persistence_token
|
81
81
|
end
|
82
|
+
|
83
|
+
create_table :ldapers do |t|
|
84
|
+
t.datetime :created_at
|
85
|
+
t.datetime :updated_at
|
86
|
+
t.string :ldap_login
|
87
|
+
t.string :persistence_token
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
require File.dirname(__FILE__) + '/../lib/authlogic' unless defined?(Authlogic)
|
@@ -87,6 +94,7 @@ require File.dirname(__FILE__) + '/libs/project'
|
|
87
94
|
require File.dirname(__FILE__) + '/libs/affiliate'
|
88
95
|
require File.dirname(__FILE__) + '/libs/employee'
|
89
96
|
require File.dirname(__FILE__) + '/libs/employee_session'
|
97
|
+
require File.dirname(__FILE__) + '/libs/ldaper'
|
90
98
|
require File.dirname(__FILE__) + '/libs/user'
|
91
99
|
require File.dirname(__FILE__) + '/libs/user_session'
|
92
100
|
require File.dirname(__FILE__) + '/libs/company'
|
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: 2.0.
|
4
|
+
version: 2.0.11
|
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: 2009-04-
|
12
|
+
date: 2009-04-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -127,9 +127,11 @@ files:
|
|
127
127
|
- test/fixtures/employees.yml
|
128
128
|
- test/fixtures/projects.yml
|
129
129
|
- test/fixtures/users.yml
|
130
|
+
- test/libs/affiliate.rb
|
130
131
|
- test/libs/company.rb
|
131
132
|
- test/libs/employee.rb
|
132
133
|
- test/libs/employee_session.rb
|
134
|
+
- test/libs/ldaper.rb
|
133
135
|
- test/libs/ordered_hash.rb
|
134
136
|
- test/libs/project.rb
|
135
137
|
- test/libs/user.rb
|