authlogic 4.4.2 → 5.0.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 +4 -4
- data/lib/authlogic/acts_as_authentic/base.rb +3 -18
- data/lib/authlogic/acts_as_authentic/email.rb +3 -170
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -1
- data/lib/authlogic/acts_as_authentic/login.rb +7 -174
- data/lib/authlogic/acts_as_authentic/magic_columns.rb +7 -4
- data/lib/authlogic/acts_as_authentic/password.rb +54 -253
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +7 -5
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +9 -4
- data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
- data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +17 -22
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +8 -6
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +9 -8
- data/lib/authlogic/config.rb +9 -1
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +7 -4
- data/lib/authlogic/controller_adapters/rack_adapter.rb +2 -0
- data/lib/authlogic/controller_adapters/rails_adapter.rb +17 -14
- data/lib/authlogic/controller_adapters/sinatra_adapter.rb +6 -0
- data/lib/authlogic/crypto_providers/bcrypt.rb +3 -3
- data/lib/authlogic/crypto_providers/md5.rb +3 -6
- data/lib/authlogic/crypto_providers/scrypt.rb +2 -0
- data/lib/authlogic/crypto_providers/sha1.rb +4 -6
- data/lib/authlogic/crypto_providers/sha256.rb +2 -0
- data/lib/authlogic/crypto_providers/sha512.rb +6 -5
- data/lib/authlogic/crypto_providers.rb +5 -20
- data/lib/authlogic/i18n/translator.rb +3 -0
- data/lib/authlogic/i18n.rb +3 -1
- data/lib/authlogic/random.rb +2 -0
- data/lib/authlogic/session/base.rb +2089 -39
- data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
- data/lib/authlogic/test_case/mock_controller.rb +2 -0
- data/lib/authlogic/test_case/mock_cookie_jar.rb +7 -0
- data/lib/authlogic/test_case/mock_logger.rb +2 -0
- data/lib/authlogic/test_case/mock_request.rb +2 -0
- data/lib/authlogic/test_case/rails_request_adapter.rb +2 -0
- data/lib/authlogic/test_case.rb +4 -0
- data/lib/authlogic/version.rb +2 -1
- data/lib/authlogic.rb +3 -28
- metadata +36 -180
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
- data/.github/ISSUE_TEMPLATE/feature_proposal.md +0 -32
- data/.github/triage.md +0 -86
- data/.gitignore +0 -15
- data/.rubocop.yml +0 -133
- data/.rubocop_todo.yml +0 -74
- data/.travis.yml +0 -24
- data/CHANGELOG.md +0 -326
- data/CONTRIBUTING.md +0 -91
- data/Gemfile +0 -6
- data/LICENSE +0 -20
- data/README.md +0 -439
- data/Rakefile +0 -21
- data/UPGRADING.md +0 -22
- data/authlogic.gemspec +0 -40
- data/doc/use_normal_rails_validation.md +0 -82
- data/gemfiles/Gemfile.rails-4.2.x +0 -6
- data/gemfiles/Gemfile.rails-5.1.x +0 -6
- data/gemfiles/Gemfile.rails-5.2.x +0 -6
- data/lib/authlogic/acts_as_authentic/restful_authentication.rb +0 -106
- data/lib/authlogic/acts_as_authentic/validations_scope.rb +0 -35
- data/lib/authlogic/authenticates_many/association.rb +0 -50
- data/lib/authlogic/authenticates_many/base.rb +0 -81
- data/lib/authlogic/crypto_providers/aes256.rb +0 -71
- data/lib/authlogic/crypto_providers/wordpress.rb +0 -72
- data/lib/authlogic/regex.rb +0 -79
- data/lib/authlogic/session/activation.rb +0 -73
- data/lib/authlogic/session/active_record_trickery.rb +0 -65
- data/lib/authlogic/session/brute_force_protection.rb +0 -127
- data/lib/authlogic/session/callbacks.rb +0 -153
- data/lib/authlogic/session/cookies.rb +0 -296
- data/lib/authlogic/session/existence.rb +0 -103
- data/lib/authlogic/session/foundation.rb +0 -105
- data/lib/authlogic/session/http_auth.rb +0 -107
- data/lib/authlogic/session/id.rb +0 -53
- data/lib/authlogic/session/klass.rb +0 -73
- data/lib/authlogic/session/magic_columns.rb +0 -119
- data/lib/authlogic/session/magic_states.rb +0 -82
- data/lib/authlogic/session/params.rb +0 -130
- data/lib/authlogic/session/password.rb +0 -318
- data/lib/authlogic/session/perishable_token.rb +0 -24
- data/lib/authlogic/session/persistence.rb +0 -77
- data/lib/authlogic/session/priority_record.rb +0 -38
- data/lib/authlogic/session/scopes.rb +0 -138
- data/lib/authlogic/session/session.rb +0 -77
- data/lib/authlogic/session/timeout.rb +0 -103
- data/lib/authlogic/session/unauthorized_record.rb +0 -56
- data/lib/authlogic/session/validation.rb +0 -93
- data/test/acts_as_authentic_test/base_test.rb +0 -27
- data/test/acts_as_authentic_test/email_test.rb +0 -241
- data/test/acts_as_authentic_test/logged_in_status_test.rb +0 -64
- data/test/acts_as_authentic_test/login_test.rb +0 -153
- data/test/acts_as_authentic_test/magic_columns_test.rb +0 -29
- data/test/acts_as_authentic_test/password_test.rb +0 -263
- data/test/acts_as_authentic_test/perishable_token_test.rb +0 -98
- data/test/acts_as_authentic_test/persistence_token_test.rb +0 -62
- data/test/acts_as_authentic_test/restful_authentication_test.rb +0 -48
- data/test/acts_as_authentic_test/session_maintenance_test.rb +0 -150
- data/test/acts_as_authentic_test/single_access_test.rb +0 -46
- data/test/adapter_test.rb +0 -23
- data/test/authenticates_many_test.rb +0 -33
- data/test/config_test.rb +0 -38
- data/test/crypto_provider_test/aes256_test.rb +0 -16
- data/test/crypto_provider_test/bcrypt_test.rb +0 -16
- data/test/crypto_provider_test/scrypt_test.rb +0 -16
- data/test/crypto_provider_test/sha1_test.rb +0 -25
- data/test/crypto_provider_test/sha256_test.rb +0 -16
- data/test/crypto_provider_test/sha512_test.rb +0 -16
- data/test/crypto_provider_test/wordpress_test.rb +0 -26
- data/test/fixtures/companies.yml +0 -5
- data/test/fixtures/employees.yml +0 -17
- data/test/fixtures/projects.yml +0 -3
- data/test/fixtures/users.yml +0 -41
- data/test/i18n/lol.yml +0 -4
- data/test/i18n_test.rb +0 -35
- data/test/libs/affiliate.rb +0 -9
- data/test/libs/company.rb +0 -8
- data/test/libs/employee.rb +0 -9
- data/test/libs/employee_session.rb +0 -4
- data/test/libs/ldaper.rb +0 -5
- data/test/libs/project.rb +0 -5
- data/test/libs/user.rb +0 -9
- data/test/libs/user_session.rb +0 -27
- data/test/random_test.rb +0 -15
- data/test/session_test/activation_test.rb +0 -45
- data/test/session_test/active_record_trickery_test.rb +0 -78
- data/test/session_test/brute_force_protection_test.rb +0 -110
- data/test/session_test/callbacks_test.rb +0 -42
- data/test/session_test/cookies_test.rb +0 -226
- data/test/session_test/credentials_test.rb +0 -0
- data/test/session_test/existence_test.rb +0 -88
- data/test/session_test/foundation_test.rb +0 -24
- data/test/session_test/http_auth_test.rb +0 -60
- data/test/session_test/id_test.rb +0 -19
- data/test/session_test/klass_test.rb +0 -42
- data/test/session_test/magic_columns_test.rb +0 -62
- data/test/session_test/magic_states_test.rb +0 -60
- data/test/session_test/params_test.rb +0 -61
- data/test/session_test/password_test.rb +0 -107
- data/test/session_test/perishability_test.rb +0 -17
- data/test/session_test/persistence_test.rb +0 -35
- data/test/session_test/scopes_test.rb +0 -68
- data/test/session_test/session_test.rb +0 -80
- data/test/session_test/timeout_test.rb +0 -84
- data/test/session_test/unauthorized_record_test.rb +0 -15
- data/test/session_test/validation_test.rb +0 -25
- data/test/test_helper.rb +0 -272
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Authlogic
|
|
2
4
|
module ActsAsAuthentic
|
|
3
5
|
# This is one of my favorite features that I think is pretty cool. It's
|
|
@@ -40,7 +42,7 @@ module Authlogic
|
|
|
40
42
|
def log_in_after_create(value = nil)
|
|
41
43
|
rw_config(:log_in_after_create, value, true)
|
|
42
44
|
end
|
|
43
|
-
|
|
45
|
+
alias log_in_after_create= log_in_after_create
|
|
44
46
|
|
|
45
47
|
# In order to turn off automatic maintenance of sessions when updating
|
|
46
48
|
# the password, just set this to false.
|
|
@@ -50,7 +52,7 @@ module Authlogic
|
|
|
50
52
|
def log_in_after_password_change(value = nil)
|
|
51
53
|
rw_config(:log_in_after_password_change, value, true)
|
|
52
54
|
end
|
|
53
|
-
|
|
55
|
+
alias log_in_after_password_change= log_in_after_password_change
|
|
54
56
|
|
|
55
57
|
# As you may know, authlogic sessions can be separate by id (See
|
|
56
58
|
# Authlogic::Session::Base#id). You can specify here what session ids
|
|
@@ -62,7 +64,7 @@ module Authlogic
|
|
|
62
64
|
def session_ids(value = nil)
|
|
63
65
|
rw_config(:session_ids, value, [nil])
|
|
64
66
|
end
|
|
65
|
-
|
|
67
|
+
alias session_ids= session_ids
|
|
66
68
|
|
|
67
69
|
# The name of the associated session class. This is inferred by the name
|
|
68
70
|
# of the model.
|
|
@@ -77,7 +79,7 @@ module Authlogic
|
|
|
77
79
|
end
|
|
78
80
|
rw_config(:session_class, value, const)
|
|
79
81
|
end
|
|
80
|
-
|
|
82
|
+
alias session_class= session_class
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
# This module, as one of the `acts_as_authentic_modules`, is only included
|
|
@@ -114,7 +116,7 @@ module Authlogic
|
|
|
114
116
|
session_class.activated? &&
|
|
115
117
|
maintain_session? &&
|
|
116
118
|
!session_ids.blank? &&
|
|
117
|
-
|
|
119
|
+
will_save_change_to_persistence_token?
|
|
118
120
|
end
|
|
119
121
|
|
|
120
122
|
def maintain_session?
|
|
@@ -174,7 +176,7 @@ module Authlogic
|
|
|
174
176
|
end
|
|
175
177
|
|
|
176
178
|
def log_in_after_password_change?
|
|
177
|
-
|
|
179
|
+
will_save_change_to_persistence_token? && self.class.log_in_after_password_change
|
|
178
180
|
end
|
|
179
181
|
end
|
|
180
182
|
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Authlogic
|
|
2
4
|
module ActsAsAuthentic
|
|
3
|
-
# This module is responsible for maintaining the single_access token. For
|
|
4
|
-
# information the single access token and how to use it, see
|
|
5
|
-
#
|
|
5
|
+
# This module is responsible for maintaining the single_access token. For
|
|
6
|
+
# more information the single access token and how to use it, see "Params"
|
|
7
|
+
# in `Session::Base`.
|
|
6
8
|
module SingleAccessToken
|
|
7
9
|
def self.included(klass)
|
|
8
10
|
klass.class_eval do
|
|
@@ -25,10 +27,7 @@ module Authlogic
|
|
|
25
27
|
def change_single_access_token_with_password(value = nil)
|
|
26
28
|
rw_config(:change_single_access_token_with_password, value, false)
|
|
27
29
|
end
|
|
28
|
-
|
|
29
|
-
:change_single_access_token_with_password=,
|
|
30
|
-
:change_single_access_token_with_password
|
|
31
|
-
)
|
|
30
|
+
alias change_single_access_token_with_password= change_single_access_token_with_password
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
# All method, for the single_access token aspect of acts_as_authentic.
|
|
@@ -41,7 +40,9 @@ module Authlogic
|
|
|
41
40
|
|
|
42
41
|
klass.class_eval do
|
|
43
42
|
include InstanceMethods
|
|
44
|
-
validates_uniqueness_of :single_access_token,
|
|
43
|
+
validates_uniqueness_of :single_access_token,
|
|
44
|
+
if: :will_save_change_to_single_access_token?
|
|
45
|
+
|
|
45
46
|
before_validation :reset_single_access_token, if: :reset_single_access_token?
|
|
46
47
|
if respond_to?(:after_password_set)
|
|
47
48
|
after_password_set(
|
data/lib/authlogic/config.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Authlogic
|
|
4
|
+
# Mixed into `Authlogic::ActsAsAuthentic::Base` and
|
|
5
|
+
# `Authlogic::Session::Base`.
|
|
2
6
|
module Config
|
|
3
|
-
E_USE_NORMAL_RAILS_VALIDATION = <<~EOS
|
|
7
|
+
E_USE_NORMAL_RAILS_VALIDATION = <<~EOS
|
|
4
8
|
This Authlogic configuration option (%s) is deprecated. Use normal
|
|
5
9
|
ActiveRecord validation instead. Detailed instructions:
|
|
6
10
|
https://github.com/binarylogic/authlogic/blob/master/doc/use_normal_rails_validation.md
|
|
@@ -8,6 +12,10 @@ module Authlogic
|
|
|
8
12
|
|
|
9
13
|
def self.extended(klass)
|
|
10
14
|
klass.class_eval do
|
|
15
|
+
# TODO: Is this a confusing name, given this module is mixed into
|
|
16
|
+
# both `Authlogic::ActsAsAuthentic::Base` and
|
|
17
|
+
# `Authlogic::Session::Base`? Perhaps a more generic name, like
|
|
18
|
+
# `authlogic_config` would be better?
|
|
11
19
|
class_attribute :acts_as_authentic_config
|
|
12
20
|
self.acts_as_authentic_config ||= {}
|
|
13
21
|
end
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Authlogic
|
|
2
4
|
module ControllerAdapters # :nodoc:
|
|
3
|
-
# Allows you to use Authlogic in any framework you want, not just rails. See
|
|
4
|
-
# for an example of how to adapt Authlogic to work with
|
|
5
|
+
# Allows you to use Authlogic in any framework you want, not just rails. See
|
|
6
|
+
# the RailsAdapter for an example of how to adapt Authlogic to work with
|
|
7
|
+
# your framework.
|
|
5
8
|
class AbstractAdapter
|
|
6
9
|
E_COOKIE_DOMAIN_ADAPTER = "The cookie_domain method has not been " \
|
|
7
|
-
"implemented by the controller adapter"
|
|
10
|
+
"implemented by the controller adapter"
|
|
8
11
|
|
|
9
12
|
attr_accessor :controller
|
|
10
13
|
|
|
@@ -26,7 +29,7 @@ module Authlogic
|
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def cookie_domain
|
|
29
|
-
raise NotImplementedError
|
|
32
|
+
raise NotImplementedError, E_COOKIE_DOMAIN_ADAPTER
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def params
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "action_controller"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
@@ -7,7 +9,19 @@ module Authlogic
|
|
|
7
9
|
# Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite,
|
|
8
10
|
# etc.
|
|
9
11
|
class RailsAdapter < AbstractAdapter
|
|
10
|
-
|
|
12
|
+
# :nodoc:
|
|
13
|
+
class AuthlogicLoadedTooLateError < StandardError
|
|
14
|
+
def message
|
|
15
|
+
<<~EOS.squish
|
|
16
|
+
Authlogic is trying to add a callback to ActionController::Base but
|
|
17
|
+
ApplicationController has already been loaded, so the callback won't
|
|
18
|
+
be copied into your application. Generally this is due to another
|
|
19
|
+
gem or plugin requiring your ApplicationController prematurely, such
|
|
20
|
+
as the resource_controller plugin. Please require Authlogic first,
|
|
21
|
+
before these other gems / plugins.
|
|
22
|
+
EOS
|
|
23
|
+
end
|
|
24
|
+
end
|
|
11
25
|
|
|
12
26
|
def authenticate_with_http_basic(&block)
|
|
13
27
|
controller.authenticate_with_http_basic(&block)
|
|
@@ -20,8 +34,7 @@ module Authlogic
|
|
|
20
34
|
end
|
|
21
35
|
|
|
22
36
|
def cookie_domain
|
|
23
|
-
|
|
24
|
-
controller.request.session_options[@cookie_domain_key]
|
|
37
|
+
controller.request.session_options[:domain]
|
|
25
38
|
end
|
|
26
39
|
|
|
27
40
|
def request_content_type
|
|
@@ -33,17 +46,7 @@ module Authlogic
|
|
|
33
46
|
module RailsImplementation
|
|
34
47
|
def self.included(klass) # :nodoc:
|
|
35
48
|
if defined?(::ApplicationController)
|
|
36
|
-
raise AuthlogicLoadedTooLateError
|
|
37
|
-
<<~EOS.squish
|
|
38
|
-
Authlogic is trying to add a callback to ActionController::Base
|
|
39
|
-
but ApplicationController has already been loaded, so the
|
|
40
|
-
callback won't be copied into your application. Generally this
|
|
41
|
-
is due to another gem or plugin requiring your
|
|
42
|
-
ApplicationController prematurely, such as the
|
|
43
|
-
resource_controller plugin. Please require Authlogic first,
|
|
44
|
-
before these other gems / plugins.
|
|
45
|
-
EOS
|
|
46
|
-
)
|
|
49
|
+
raise AuthlogicLoadedTooLateError
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
# In Rails 4.0.2, the *_filter methods were renamed to *_action.
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Authlogic bridge for Sinatra
|
|
2
4
|
module Authlogic
|
|
3
5
|
module ControllerAdapters
|
|
4
6
|
module SinatraAdapter
|
|
7
|
+
# Cookie management functions
|
|
5
8
|
class Cookies
|
|
6
9
|
attr_reader :request, :response
|
|
7
10
|
|
|
@@ -23,6 +26,7 @@ module Authlogic
|
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
29
|
+
# Thin wrapper around request and response.
|
|
26
30
|
class Controller
|
|
27
31
|
attr_reader :request, :response, :cookies
|
|
28
32
|
|
|
@@ -40,11 +44,13 @@ module Authlogic
|
|
|
40
44
|
end
|
|
41
45
|
end
|
|
42
46
|
|
|
47
|
+
# Sinatra controller adapter
|
|
43
48
|
class Adapter < AbstractAdapter
|
|
44
49
|
def cookie_domain
|
|
45
50
|
env["SERVER_NAME"]
|
|
46
51
|
end
|
|
47
52
|
|
|
53
|
+
# Mixed into `Sinatra::Base`
|
|
48
54
|
module Implementation
|
|
49
55
|
def self.included(klass)
|
|
50
56
|
klass.send :before do
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bcrypt"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
@@ -64,10 +66,8 @@ module Authlogic
|
|
|
64
66
|
|
|
65
67
|
def cost=(val)
|
|
66
68
|
if val < ::BCrypt::Engine::MIN_COST
|
|
67
|
-
raise ArgumentError
|
|
68
|
-
"Authlogic's bcrypt cost cannot be set below the engine's " \
|
|
69
|
+
raise ArgumentError, "Authlogic's bcrypt cost cannot be set below the engine's " \
|
|
69
70
|
"min cost (#{::BCrypt::Engine::MIN_COST})"
|
|
70
|
-
)
|
|
71
71
|
end
|
|
72
72
|
@cost = val
|
|
73
73
|
end
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "digest/md5"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
4
6
|
module CryptoProviders
|
|
5
|
-
#
|
|
6
|
-
# I highly discourage using this crypto provider as it superbly inferior
|
|
7
|
-
# to your other options.
|
|
8
|
-
#
|
|
9
|
-
# Please use any other provider offered by Authlogic (except AES256, that
|
|
10
|
-
# would be even worse).
|
|
7
|
+
# A poor choice. There are known attacks against this algorithm.
|
|
11
8
|
class MD5
|
|
12
9
|
class << self
|
|
13
10
|
attr_accessor :join_token
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "digest/sha1"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
4
6
|
module CryptoProviders
|
|
5
|
-
#
|
|
6
|
-
# restful_authentication. Use of this crypto provider is highly discouraged.
|
|
7
|
-
# It is far inferior to your other options. Please use any other provider
|
|
8
|
-
# offered by Authlogic.
|
|
7
|
+
# A poor choice. There are known attacks against this algorithm.
|
|
9
8
|
class Sha1
|
|
10
9
|
class << self
|
|
11
10
|
def join_token
|
|
@@ -13,8 +12,7 @@ module Authlogic
|
|
|
13
12
|
end
|
|
14
13
|
attr_writer :join_token
|
|
15
14
|
|
|
16
|
-
# The number of times to loop through the encryption.
|
|
17
|
-
# because that is what restful_authentication defaults to.
|
|
15
|
+
# The number of times to loop through the encryption.
|
|
18
16
|
def stretches
|
|
19
17
|
@stretches ||= 10
|
|
20
18
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "digest/sha2"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
4
6
|
module CryptoProviders
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
7
|
+
# SHA-512 does not have any practical known attacks against it. However,
|
|
8
|
+
# there are better choices. We recommend transitioning to a more secure,
|
|
9
|
+
# adaptive hashing algorithm, like scrypt.
|
|
8
10
|
class Sha512
|
|
9
11
|
class << self
|
|
10
12
|
attr_accessor :join_token
|
|
11
13
|
|
|
12
|
-
# The number of times to loop through the encryption.
|
|
13
|
-
# because that is what restful_authentication defaults to.
|
|
14
|
+
# The number of times to loop through the encryption.
|
|
14
15
|
def stretches
|
|
15
16
|
@stretches ||= 20
|
|
16
17
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Authlogic
|
|
2
4
|
# The acts_as_authentic method has a crypto_provider option. This allows you
|
|
3
5
|
# to use any type of encryption you like. Just create a class with a class
|
|
@@ -26,27 +28,12 @@ module Authlogic
|
|
|
26
28
|
autoload :Sha256, "authlogic/crypto_providers/sha256"
|
|
27
29
|
autoload :Sha512, "authlogic/crypto_providers/sha512"
|
|
28
30
|
autoload :BCrypt, "authlogic/crypto_providers/bcrypt"
|
|
29
|
-
autoload :AES256, "authlogic/crypto_providers/aes256"
|
|
30
31
|
autoload :SCrypt, "authlogic/crypto_providers/scrypt"
|
|
31
|
-
# crypto_providers/wordpress.rb has never been autoloaded, and now it is
|
|
32
|
-
# deprecated.
|
|
33
32
|
|
|
34
33
|
# Guide users to choose a better crypto provider.
|
|
35
34
|
class Guidance
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
choice is not suitable for password storage.
|
|
39
|
-
|
|
40
|
-
Authlogic will drop its AES256 crypto provider in the next major
|
|
41
|
-
version. If you're unable to transition away from AES256 please let us
|
|
42
|
-
know immediately.
|
|
43
|
-
|
|
44
|
-
We recommend using a one-way algorithm instead. There are many choices;
|
|
45
|
-
we recommend scrypt. Use the transition_from_crypto_providers option
|
|
46
|
-
to make this painless for your users.
|
|
47
|
-
EOS
|
|
48
|
-
BUILTIN_PROVIDER_PREFIX = "Authlogic::CryptoProviders::".freeze
|
|
49
|
-
NONADAPTIVE_ALGORITHM = <<~EOS.freeze
|
|
35
|
+
BUILTIN_PROVIDER_PREFIX = "Authlogic::CryptoProviders::"
|
|
36
|
+
NONADAPTIVE_ALGORITHM = <<~EOS
|
|
50
37
|
You have selected %s as your authlogic crypto provider. This algorithm
|
|
51
38
|
does not have any practical known attacks against it. However, there are
|
|
52
39
|
better choices.
|
|
@@ -61,7 +48,7 @@ module Authlogic
|
|
|
61
48
|
Use the transition_from_crypto_providers option to make the transition
|
|
62
49
|
painless for your users.
|
|
63
50
|
EOS
|
|
64
|
-
VULNERABLE_ALGORITHM = <<~EOS
|
|
51
|
+
VULNERABLE_ALGORITHM = <<~EOS
|
|
65
52
|
You have selected %s as your authlogic crypto provider. It is a poor
|
|
66
53
|
choice because there are known attacks against this algorithm.
|
|
67
54
|
|
|
@@ -89,8 +76,6 @@ module Authlogic
|
|
|
89
76
|
# negate the benefits of the `autoload` above.
|
|
90
77
|
name = absolute_name.demodulize
|
|
91
78
|
case name
|
|
92
|
-
when "AES256"
|
|
93
|
-
::ActiveSupport::Deprecation.warn(AES256_DEPRECATED)
|
|
94
79
|
when "MD5", "Sha1"
|
|
95
80
|
warn(format(VULNERABLE_ALGORITHM, name))
|
|
96
81
|
when "Sha256", "Sha512"
|
data/lib/authlogic/i18n.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "authlogic/i18n/translator"
|
|
2
4
|
|
|
3
5
|
module Authlogic
|
|
@@ -92,7 +94,7 @@ module Authlogic
|
|
|
92
94
|
def translate(key, options = {})
|
|
93
95
|
translator.translate key, { scope: I18n.scope }.merge(options)
|
|
94
96
|
end
|
|
95
|
-
alias
|
|
97
|
+
alias t translate
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
end
|