Skip to content

Commit 74e4687

Browse files
committed
💥 Add SASL::Authenticators defaults, by default
Reversed the `use_defaults` default, and added another option for `use_deprecated`.
1 parent 9c8fbdb commit 74e4687

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

lib/net/imap/sasl.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ module SASL
141141
autoload :LoginAuthenticator, "#{sasl_dir}/login_authenticator"
142142

143143
# Returns the default global SASL::Authenticators instance.
144-
def self.authenticators
145-
@authenticators ||= Authenticators.new(use_defaults: true)
146-
end
144+
def self.authenticators; @authenticators ||= Authenticators.new end
147145

148146
# Delegates to ::authenticators. See Authenticators#authenticator.
149147
def self.authenticator(...) authenticators.authenticator(...) end

lib/net/imap/sasl/authenticators.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ class Authenticators
2626
# This class is usually not instantiated directly. Use SASL.authenticators
2727
# to reuse the default global registry.
2828
#
29-
# By default, the registry will be empty--without any registrations. When
30-
# +add_defaults+ is +true+, authenticators for all standard mechanisms will
31-
# be registered.
32-
#
33-
def initialize(use_defaults: false)
29+
# When +use_defaults+ is +false+, the registry will start empty. When
30+
# +use_deprecated+ is +false+, deprecated authenticators will not be
31+
# included with the defaults.
32+
def initialize(use_defaults: true, use_deprecated: true)
3433
@authenticators = {}
35-
if use_defaults
36-
add_authenticator "Anonymous"
37-
add_authenticator "External"
38-
add_authenticator "OAuthBearer"
39-
add_authenticator "Plain"
40-
add_authenticator "Scram-SHA-1"
41-
add_authenticator "Scram-SHA-256"
42-
add_authenticator "XOAuth2"
43-
add_authenticator "Login" # deprecated
44-
add_authenticator "Cram-MD5" # deprecated
45-
add_authenticator "Digest-MD5" # deprecated
46-
end
34+
return unless use_defaults
35+
add_authenticator "Anonymous"
36+
add_authenticator "External"
37+
add_authenticator "OAuthBearer"
38+
add_authenticator "Plain"
39+
add_authenticator "Scram-SHA-1"
40+
add_authenticator "Scram-SHA-256"
41+
add_authenticator "XOAuth2"
42+
return unless use_deprecated
43+
add_authenticator "Login" # deprecated
44+
add_authenticator "Cram-MD5" # deprecated
45+
add_authenticator "Digest-MD5" # deprecated
4746
end
4847

4948
# Returns the names of all registered SASL mechanisms.

0 commit comments

Comments
 (0)