authlogic 3.8.0 → 4.5.0
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 +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- data/.github/ISSUE_TEMPLATE/feature_proposal.md +32 -0
- data/.github/triage.md +86 -0
- data/.gitignore +4 -3
- data/.rubocop.yml +109 -9
- data/.rubocop_todo.yml +38 -355
- data/.travis.yml +11 -35
- data/CHANGELOG.md +345 -2
- data/CONTRIBUTING.md +45 -14
- data/Gemfile +3 -2
- data/README.md +244 -90
- data/Rakefile +10 -10
- data/UPGRADING.md +22 -0
- data/authlogic.gemspec +34 -21
- data/doc/use_normal_rails_validation.md +82 -0
- data/gemfiles/Gemfile.rails-4.2.x +6 -0
- data/{test/gemfiles → gemfiles}/Gemfile.rails-5.1.x +2 -2
- data/{test/gemfiles → gemfiles}/Gemfile.rails-5.2.x +2 -2
- data/lib/authlogic/acts_as_authentic/base.rb +36 -24
- data/lib/authlogic/acts_as_authentic/email.rb +65 -31
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +14 -9
- data/lib/authlogic/acts_as_authentic/login.rb +61 -45
- data/lib/authlogic/acts_as_authentic/magic_columns.rb +6 -6
- data/lib/authlogic/acts_as_authentic/password.rb +267 -146
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +24 -19
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +10 -15
- data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +67 -0
- data/lib/authlogic/acts_as_authentic/restful_authentication.rb +50 -14
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +88 -60
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +23 -11
- data/lib/authlogic/acts_as_authentic/validations_scope.rb +9 -6
- data/lib/authlogic/authenticates_many/association.rb +7 -7
- data/lib/authlogic/authenticates_many/base.rb +37 -21
- data/lib/authlogic/config.rb +21 -10
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +38 -11
- data/lib/authlogic/controller_adapters/rack_adapter.rb +9 -5
- data/lib/authlogic/controller_adapters/rails_adapter.rb +12 -7
- data/lib/authlogic/controller_adapters/sinatra_adapter.rb +2 -2
- data/lib/authlogic/crypto_providers/aes256.rb +37 -32
- data/lib/authlogic/crypto_providers/bcrypt.rb +21 -15
- data/lib/authlogic/crypto_providers/md5.rb +4 -2
- data/lib/authlogic/crypto_providers/scrypt.rb +22 -17
- data/lib/authlogic/crypto_providers/sha1.rb +11 -5
- data/lib/authlogic/crypto_providers/sha256.rb +13 -9
- data/lib/authlogic/crypto_providers/sha512.rb +0 -21
- data/lib/authlogic/crypto_providers/wordpress.rb +32 -3
- data/lib/authlogic/crypto_providers.rb +91 -0
- data/lib/authlogic/i18n.rb +26 -19
- data/lib/authlogic/random.rb +10 -28
- data/lib/authlogic/regex.rb +59 -28
- data/lib/authlogic/session/activation.rb +10 -7
- data/lib/authlogic/session/active_record_trickery.rb +13 -9
- data/lib/authlogic/session/base.rb +15 -4
- data/lib/authlogic/session/brute_force_protection.rb +40 -33
- data/lib/authlogic/session/callbacks.rb +94 -46
- data/lib/authlogic/session/cookies.rb +130 -45
- data/lib/authlogic/session/existence.rb +21 -11
- data/lib/authlogic/session/foundation.rb +64 -14
- data/lib/authlogic/session/http_auth.rb +35 -28
- data/lib/authlogic/session/id.rb +9 -4
- data/lib/authlogic/session/klass.rb +15 -12
- data/lib/authlogic/session/magic_columns.rb +58 -55
- data/lib/authlogic/session/magic_states.rb +25 -19
- data/lib/authlogic/session/params.rb +42 -28
- data/lib/authlogic/session/password.rb +130 -120
- data/lib/authlogic/session/perishable_token.rb +5 -4
- data/lib/authlogic/session/persistence.rb +18 -12
- data/lib/authlogic/session/priority_record.rb +15 -12
- data/lib/authlogic/session/scopes.rb +51 -32
- data/lib/authlogic/session/session.rb +38 -28
- data/lib/authlogic/session/timeout.rb +13 -13
- data/lib/authlogic/session/unauthorized_record.rb +18 -13
- data/lib/authlogic/session/validation.rb +9 -9
- data/lib/authlogic/test_case/mock_controller.rb +5 -4
- data/lib/authlogic/test_case/mock_cookie_jar.rb +47 -3
- data/lib/authlogic/test_case/mock_request.rb +6 -3
- data/lib/authlogic/test_case/rails_request_adapter.rb +3 -2
- data/lib/authlogic/test_case.rb +70 -2
- data/lib/authlogic/version.rb +21 -0
- data/lib/authlogic.rb +51 -49
- data/test/acts_as_authentic_test/base_test.rb +3 -1
- data/test/acts_as_authentic_test/email_test.rb +43 -42
- data/test/acts_as_authentic_test/logged_in_status_test.rb +6 -4
- data/test/acts_as_authentic_test/login_test.rb +77 -80
- data/test/acts_as_authentic_test/magic_columns_test.rb +3 -1
- data/test/acts_as_authentic_test/password_test.rb +51 -37
- data/test/acts_as_authentic_test/perishable_token_test.rb +13 -5
- data/test/acts_as_authentic_test/persistence_token_test.rb +7 -1
- data/test/acts_as_authentic_test/restful_authentication_test.rb +14 -3
- data/test/acts_as_authentic_test/session_maintenance_test.rb +69 -15
- data/test/acts_as_authentic_test/single_access_test.rb +3 -1
- data/test/adapter_test.rb +23 -0
- data/test/authenticates_many_test.rb +3 -1
- data/test/config_test.rb +11 -9
- data/test/crypto_provider_test/aes256_test.rb +3 -1
- data/test/crypto_provider_test/bcrypt_test.rb +3 -1
- data/test/crypto_provider_test/scrypt_test.rb +3 -1
- data/test/crypto_provider_test/sha1_test.rb +3 -1
- data/test/crypto_provider_test/sha256_test.rb +3 -1
- data/test/crypto_provider_test/sha512_test.rb +3 -1
- data/test/crypto_provider_test/wordpress_test.rb +26 -0
- data/test/fixtures/companies.yml +2 -2
- data/test/fixtures/employees.yml +1 -1
- data/test/i18n_test.rb +6 -4
- data/test/libs/affiliate.rb +2 -0
- data/test/libs/company.rb +4 -2
- data/test/libs/employee.rb +2 -0
- data/test/libs/employee_session.rb +2 -0
- data/test/libs/ldaper.rb +2 -0
- data/test/libs/project.rb +2 -0
- data/test/libs/user.rb +2 -0
- data/test/libs/user_session.rb +4 -2
- data/test/random_test.rb +10 -38
- data/test/session_test/activation_test.rb +3 -1
- data/test/session_test/active_record_trickery_test.rb +7 -4
- data/test/session_test/brute_force_protection_test.rb +11 -9
- data/test/session_test/callbacks_test.rb +12 -4
- data/test/session_test/cookies_test.rb +48 -5
- data/test/session_test/existence_test.rb +18 -5
- data/test/session_test/foundation_test.rb +19 -1
- data/test/session_test/http_auth_test.rb +11 -7
- data/test/session_test/id_test.rb +3 -1
- data/test/session_test/klass_test.rb +3 -1
- data/test/session_test/magic_columns_test.rb +13 -13
- data/test/session_test/magic_states_test.rb +3 -1
- data/test/session_test/params_test.rb +13 -5
- data/test/session_test/password_test.rb +10 -8
- data/test/session_test/perishability_test.rb +3 -1
- data/test/session_test/persistence_test.rb +4 -1
- data/test/session_test/scopes_test.rb +16 -8
- data/test/session_test/session_test.rb +6 -4
- data/test/session_test/timeout_test.rb +4 -2
- data/test/session_test/unauthorized_record_test.rb +4 -2
- data/test/session_test/validation_test.rb +3 -1
- data/test/test_helper.rb +84 -45
- metadata +87 -73
- data/.github/ISSUE_TEMPLATE.md +0 -13
- data/test/gemfiles/Gemfile.rails-3.2.x +0 -7
- data/test/gemfiles/Gemfile.rails-4.0.x +0 -7
- data/test/gemfiles/Gemfile.rails-4.1.x +0 -7
- data/test/gemfiles/Gemfile.rails-4.2.x +0 -7
- data/test/gemfiles/Gemfile.rails-5.0.x +0 -6
@@ -41,7 +41,7 @@ module Authlogic
|
|
41
41
|
# they login and then leave the website, when do mark them as logged
|
42
42
|
# out? I recommend just using this as a fun feature on your website or
|
43
43
|
# reports, giving you a ballpark number of users logged in and active.
|
44
|
-
# This is not meant to be a dead accurate representation of a
|
44
|
+
# This is not meant to be a dead accurate representation of a user's
|
45
45
|
# logged in state, since there is really no real way to do this with web
|
46
46
|
# based apps. Think about a user that logs in and doesn't log out. There
|
47
47
|
# is no action that tells you that the user isn't technically still
|
@@ -52,7 +52,7 @@ module Authlogic
|
|
52
52
|
# this option to true and if your record returns true for stale? then
|
53
53
|
# they will be required to log back in.
|
54
54
|
#
|
55
|
-
# Lastly, UserSession.find will still return
|
55
|
+
# Lastly, UserSession.find will still return an object if the session is
|
56
56
|
# stale, but you will not get a record. This allows you to determine if
|
57
57
|
# the user needs to log back in because their session went stale, or
|
58
58
|
# because they just aren't logged in. Just call
|
@@ -83,20 +83,20 @@ module Authlogic
|
|
83
83
|
|
84
84
|
private
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
def reset_stale_state
|
87
|
+
self.stale_record = nil
|
88
|
+
end
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
90
|
+
def enforce_timeout
|
91
|
+
if stale?
|
92
|
+
self.stale_record = record
|
93
|
+
self.record = nil
|
95
94
|
end
|
95
|
+
end
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
def logout_on_timeout?
|
98
|
+
self.class.logout_on_timeout == true
|
99
|
+
end
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -4,18 +4,23 @@ module Authlogic
|
|
4
4
|
#
|
5
5
|
# UserSession.create(my_user_object)
|
6
6
|
#
|
7
|
-
# Be careful with this, because Authlogic is assuming that you have already
|
8
|
-
# user is who he says he is.
|
7
|
+
# Be careful with this, because Authlogic is assuming that you have already
|
8
|
+
# confirmed that the user is who he says he is.
|
9
9
|
#
|
10
|
-
# For example, this is the method used to persist the session internally.
|
11
|
-
# the persistence token. At this point we know
|
12
|
-
#
|
13
|
-
#
|
10
|
+
# For example, this is the method used to persist the session internally.
|
11
|
+
# Authlogic finds the user with the persistence token. At this point we know
|
12
|
+
# the user is who he says he is, so Authlogic just creates a session with
|
13
|
+
# the record. This is particularly useful for 3rd party authentication
|
14
|
+
# methods, such as OpenID. Let that method verify the identity, once it's
|
15
|
+
# verified, pass the object and create a session.
|
14
16
|
module UnauthorizedRecord
|
15
17
|
def self.included(klass)
|
16
18
|
klass.class_eval do
|
17
19
|
attr_accessor :unauthorized_record
|
18
|
-
validate
|
20
|
+
validate(
|
21
|
+
:validate_by_unauthorized_record,
|
22
|
+
if: :authenticating_with_unauthorized_record?
|
23
|
+
)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
@@ -39,13 +44,13 @@ module Authlogic
|
|
39
44
|
|
40
45
|
private
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
def authenticating_with_unauthorized_record?
|
48
|
+
!unauthorized_record.nil?
|
49
|
+
end
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
def validate_by_unauthorized_record
|
52
|
+
self.attempted_record = unauthorized_record
|
53
|
+
end
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -77,17 +77,17 @@ module Authlogic
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
)
|
80
|
+
def ensure_authentication_attempted
|
81
|
+
if errors.empty? && attempted_record.nil?
|
82
|
+
errors.add(
|
83
|
+
:base,
|
84
|
+
I18n.t(
|
85
|
+
"error_messages.no_authentication_details",
|
86
|
+
default: "You did not provide any details for authentication."
|
88
87
|
)
|
89
|
-
|
88
|
+
)
|
90
89
|
end
|
90
|
+
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module TestCase
|
3
|
-
# Basically acts like a controller but doesn't do anything. Authlogic can interact
|
4
|
-
# can look at the controller object to see if
|
3
|
+
# Basically acts like a controller but doesn't do anything. Authlogic can interact
|
4
|
+
# with this, do it's thing and then you can look at the controller object to see if
|
5
|
+
# anything changed.
|
5
6
|
class MockController < ControllerAdapters::AbstractAdapter
|
6
7
|
attr_accessor :http_user, :http_password, :realm
|
7
8
|
attr_writer :request_content_type
|
@@ -9,11 +10,11 @@ module Authlogic
|
|
9
10
|
def initialize
|
10
11
|
end
|
11
12
|
|
12
|
-
def authenticate_with_http_basic
|
13
|
+
def authenticate_with_http_basic
|
13
14
|
yield http_user, http_password
|
14
15
|
end
|
15
16
|
|
16
|
-
def authenticate_or_request_with_http_basic(realm =
|
17
|
+
def authenticate_or_request_with_http_basic(realm = "DefaultRealm")
|
17
18
|
self.realm = realm
|
18
19
|
@http_auth_requested = true
|
19
20
|
yield http_user, http_password
|
@@ -1,18 +1,30 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module TestCase
|
3
|
+
# A mock of `ActionDispatch::Cookies::CookieJar`.
|
3
4
|
class MockCookieJar < Hash # :nodoc:
|
5
|
+
attr_accessor :set_cookies
|
6
|
+
|
4
7
|
def [](key)
|
5
8
|
hash = super
|
6
9
|
hash && hash[:value]
|
7
10
|
end
|
8
11
|
|
9
|
-
def
|
12
|
+
def []=(key, options)
|
13
|
+
(@set_cookies ||= {})[key.to_s] = options
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete(key, _options = {})
|
10
18
|
super(key)
|
11
19
|
end
|
12
20
|
|
13
21
|
def signed
|
14
22
|
@signed ||= MockSignedCookieJar.new(self)
|
15
23
|
end
|
24
|
+
|
25
|
+
def encrypted
|
26
|
+
@encrypted ||= MockEncryptedCookieJar.new(self)
|
27
|
+
end
|
16
28
|
end
|
17
29
|
|
18
30
|
class MockSignedCookieJar < MockCookieJar
|
@@ -20,11 +32,13 @@ module Authlogic
|
|
20
32
|
|
21
33
|
def initialize(parent_jar)
|
22
34
|
@parent_jar = parent_jar
|
35
|
+
parent_jar.each { |k, v| self[k] = v }
|
23
36
|
end
|
24
37
|
|
25
38
|
def [](val)
|
26
|
-
|
27
|
-
|
39
|
+
signed_message = @parent_jar[val]
|
40
|
+
if signed_message
|
41
|
+
payload, signature = signed_message.split("--")
|
28
42
|
raise "Invalid signature" unless Digest::SHA1.hexdigest(payload) == signature
|
29
43
|
payload
|
30
44
|
end
|
@@ -35,5 +49,35 @@ module Authlogic
|
|
35
49
|
@parent_jar[key] = options
|
36
50
|
end
|
37
51
|
end
|
52
|
+
|
53
|
+
class MockEncryptedCookieJar < MockCookieJar
|
54
|
+
attr_reader :parent_jar # helper for testing
|
55
|
+
|
56
|
+
def initialize(parent_jar)
|
57
|
+
@parent_jar = parent_jar
|
58
|
+
parent_jar.each { |k, v| self[k] = v }
|
59
|
+
end
|
60
|
+
|
61
|
+
def [](val)
|
62
|
+
encrypted_message = @parent_jar[val]
|
63
|
+
if encrypted_message
|
64
|
+
self.class.decrypt(encrypted_message)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def []=(key, options)
|
69
|
+
options[:value] = self.class.encrypt(options[:value])
|
70
|
+
@parent_jar[key] = options
|
71
|
+
end
|
72
|
+
|
73
|
+
# simple caesar cipher for testing
|
74
|
+
def self.encrypt(str)
|
75
|
+
str.unpack("U*").map(&:succ).pack("U*")
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.decrypt(str)
|
79
|
+
str.unpack("U*").map(&:pred).pack("U*")
|
80
|
+
end
|
81
|
+
end
|
38
82
|
end
|
39
83
|
end
|
@@ -8,13 +8,16 @@ module Authlogic
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def ip
|
11
|
-
|
11
|
+
controller&.respond_to?(:env) &&
|
12
|
+
controller.env.is_a?(Hash) &&
|
13
|
+
controller.env["REMOTE_ADDR"] ||
|
14
|
+
"1.1.1.1"
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
def method_missing(*args, &block)
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Authlogic
|
2
2
|
module TestCase
|
3
|
-
# Adapts authlogic to work with the @request object when testing. This way Authlogic
|
4
|
-
# a request is made, ultimately letting you log in
|
3
|
+
# Adapts authlogic to work with the @request object when testing. This way Authlogic
|
4
|
+
# can set cookies and what not before a request is made, ultimately letting you log in
|
5
|
+
# users in functional tests.
|
5
6
|
class RailsRequestAdapter < ControllerAdapters::AbstractAdapter
|
6
7
|
def authenticate_with_http_basic(&block)
|
7
8
|
end
|
data/lib/authlogic/test_case.rb
CHANGED
@@ -50,7 +50,7 @@ module Authlogic
|
|
50
50
|
# ben:
|
51
51
|
# email: whatever@whatever.com
|
52
52
|
# password_salt: <%= salt = Authlogic::Random.hex_token %>
|
53
|
-
# crypted_password: <%= Authlogic::CryptoProviders::
|
53
|
+
# crypted_password: <%= Authlogic::CryptoProviders::SCrypt.encrypt("benrocks" + salt) %>
|
54
54
|
# persistence_token: <%= Authlogic::Random.hex_token %>
|
55
55
|
# single_access_token: <%= Authlogic::Random.friendly_token %>
|
56
56
|
# perishable_token: <%= Authlogic::Random.friendly_token %>
|
@@ -113,7 +113,73 @@ module Authlogic
|
|
113
113
|
#
|
114
114
|
# See how I am checking that Authlogic is interacting with the controller
|
115
115
|
# properly? That's the idea here.
|
116
|
+
#
|
117
|
+
# === Testing with Rails 5
|
118
|
+
#
|
119
|
+
# Rails 5 has [deprecated classic controller tests](https://goo.gl/4zmt6y).
|
120
|
+
# Controller tests now inherit from `ActionDispatch::IntegrationTest` making
|
121
|
+
# them plain old integration tests now. You have two options for testing
|
122
|
+
# AuthLogic in Rails 5:
|
123
|
+
#
|
124
|
+
# * Add the `rails-controller-testing` gem to bring back the original
|
125
|
+
# controller testing usage
|
126
|
+
# * Go full steam ahead with integration testing and actually log a user in
|
127
|
+
# by submitting a form in the integration test.
|
128
|
+
#
|
129
|
+
# Naturally DHH recommends the second method and this is
|
130
|
+
# [what he does in his own tests](https://goo.gl/Ar6p0u). This is useful
|
131
|
+
# for testing not only AuthLogic itself (submitting login credentials to a
|
132
|
+
# UserSessionsController, for example) but any controller action that is
|
133
|
+
# behind a login wall. Add a helper method and use that before testing your
|
134
|
+
# actual controller action:
|
135
|
+
#
|
136
|
+
# # test/test_helper.rb
|
137
|
+
# def login(user)
|
138
|
+
# post user_sessions_url, :params => { :email => user.email, :password => 'password' }
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# # test/controllers/posts_controller_test.rb
|
142
|
+
# test "#create requires a user to be logged in
|
143
|
+
# post posts_url, :params => { :body => 'Lorem ipsum' }
|
144
|
+
#
|
145
|
+
# assert_redirected_to new_user_session_url
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# test "#create lets a logged in user create a new post" do
|
149
|
+
# login(users(:admin))
|
150
|
+
#
|
151
|
+
# assert_difference 'Posts.count' do
|
152
|
+
# post posts_url, :params => { :body => 'Lorem ipsum' }
|
153
|
+
# end
|
154
|
+
#
|
155
|
+
# assert_redirected_to posts_url
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# You still have access to the `session` helper in an integration test and so
|
159
|
+
# you can still test to see if a user is logged in. A couple of helper methods
|
160
|
+
# might look like:
|
161
|
+
#
|
162
|
+
# # test/test_helper.rb
|
163
|
+
# def assert_logged_in
|
164
|
+
# assert session[:user_credentials].present?
|
165
|
+
# end
|
166
|
+
#
|
167
|
+
# def assert_not_logged_in
|
168
|
+
# assert session[:user_credentials].blank?
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# # test/user_sessions_controller_test.rb
|
172
|
+
# test "#create logs in a user" do
|
173
|
+
# login(users(:admin))
|
174
|
+
#
|
175
|
+
# assert_logged_in
|
176
|
+
# end
|
116
177
|
module TestCase
|
178
|
+
def initialize(*args)
|
179
|
+
@request = nil
|
180
|
+
super
|
181
|
+
end
|
182
|
+
|
117
183
|
# Activates authlogic so that you can use it in your tests. You should call
|
118
184
|
# this method in your test's setup. Ex:
|
119
185
|
#
|
@@ -125,7 +191,9 @@ module Authlogic
|
|
125
191
|
end
|
126
192
|
end
|
127
193
|
|
128
|
-
Authlogic::Session::Base.controller =
|
194
|
+
Authlogic::Session::Base.controller = @request &&
|
195
|
+
Authlogic::TestCase::RailsRequestAdapter.new(@request) ||
|
196
|
+
controller
|
129
197
|
end
|
130
198
|
|
131
199
|
# The Authlogic::TestCase::MockController object passed to Authlogic to
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
module Authlogic
|
6
|
+
# Returns a `::Gem::Version`, the version number of the authlogic gem.
|
7
|
+
#
|
8
|
+
# It is preferable for a library to provide a `gem_version` method, rather
|
9
|
+
# than a `VERSION` string, because `::Gem::Version` is easier to use in a
|
10
|
+
# comparison.
|
11
|
+
#
|
12
|
+
# We cannot return a frozen `Version`, because rubygems will try to modify it.
|
13
|
+
# https://github.com/binarylogic/authlogic/pull/590
|
14
|
+
#
|
15
|
+
# Added in 4.0.0
|
16
|
+
#
|
17
|
+
# @api public
|
18
|
+
def self.gem_version
|
19
|
+
::Gem::Version.new("4.5.0")
|
20
|
+
end
|
21
|
+
end
|
data/lib/authlogic.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# Authlogic uses ActiveSupport's core extensions like `strip_heredoc
|
2
|
-
# ActiveRecord does not `require
|
3
|
-
#
|
4
|
-
#
|
1
|
+
# Authlogic uses ActiveSupport's core extensions like `strip_heredoc` and
|
2
|
+
# `squish`. ActiveRecord does not `require` these exensions, so we must.
|
3
|
+
#
|
4
|
+
# It's possible that we could save a few milliseconds by loading only the
|
5
|
+
# specific core extensions we need, but `all.rb` is simpler. We can revisit this
|
6
|
+
# decision if it becomes a problem.
|
5
7
|
require "active_support/all"
|
6
8
|
|
7
9
|
require "active_record"
|
@@ -9,57 +11,57 @@ require "active_record"
|
|
9
11
|
path = File.dirname(__FILE__) + "/authlogic/"
|
10
12
|
|
11
13
|
[
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
"i18n",
|
15
|
+
"random",
|
16
|
+
"regex",
|
17
|
+
"config",
|
16
18
|
|
17
|
-
|
19
|
+
"controller_adapters/abstract_adapter",
|
18
20
|
|
19
|
-
|
21
|
+
"crypto_providers",
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
"authenticates_many/base",
|
24
|
+
"authenticates_many/association",
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
"acts_as_authentic/email",
|
27
|
+
"acts_as_authentic/logged_in_status",
|
28
|
+
"acts_as_authentic/login",
|
29
|
+
"acts_as_authentic/magic_columns",
|
30
|
+
"acts_as_authentic/password",
|
31
|
+
"acts_as_authentic/perishable_token",
|
32
|
+
"acts_as_authentic/persistence_token",
|
33
|
+
"acts_as_authentic/restful_authentication",
|
34
|
+
"acts_as_authentic/session_maintenance",
|
35
|
+
"acts_as_authentic/single_access_token",
|
36
|
+
"acts_as_authentic/validations_scope",
|
37
|
+
"acts_as_authentic/base",
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
39
|
+
"session/activation",
|
40
|
+
"session/active_record_trickery",
|
41
|
+
"session/brute_force_protection",
|
42
|
+
"session/callbacks",
|
43
|
+
"session/cookies",
|
44
|
+
"session/existence",
|
45
|
+
"session/foundation",
|
46
|
+
"session/http_auth",
|
47
|
+
"session/id",
|
48
|
+
"session/klass",
|
49
|
+
"session/magic_columns",
|
50
|
+
"session/magic_states",
|
51
|
+
"session/params",
|
52
|
+
"session/password",
|
53
|
+
"session/perishable_token",
|
54
|
+
"session/persistence",
|
55
|
+
"session/priority_record",
|
56
|
+
"session/scopes",
|
57
|
+
"session/session",
|
58
|
+
"session/timeout",
|
59
|
+
"session/unauthorized_record",
|
60
|
+
"session/validation",
|
61
|
+
"session/base"
|
60
62
|
].each do |library|
|
61
|
-
|
62
|
-
|
63
|
+
require path + library
|
64
|
+
end
|
63
65
|
|
64
66
|
require path + "controller_adapters/rails_adapter" if defined?(Rails)
|
65
67
|
require path + "controller_adapters/sinatra_adapter" if defined?(Sinatra)
|