diff --git a/lib/net/imap/sasl.rb b/lib/net/imap/sasl.rb index 4af1c4be..353bef62 100644 --- a/lib/net/imap/sasl.rb +++ b/lib/net/imap/sasl.rb @@ -141,9 +141,7 @@ module SASL autoload :LoginAuthenticator, "#{sasl_dir}/login_authenticator" # Returns the default global SASL::Authenticators instance. - def self.authenticators - @authenticators ||= Authenticators.new(use_defaults: true) - end + def self.authenticators; @authenticators ||= Authenticators.new end # Delegates to ::authenticators. See Authenticators#authenticator. def self.authenticator(...) authenticators.authenticator(...) end diff --git a/lib/net/imap/sasl/authenticators.rb b/lib/net/imap/sasl/authenticators.rb index 88d5feb5..7536630b 100644 --- a/lib/net/imap/sasl/authenticators.rb +++ b/lib/net/imap/sasl/authenticators.rb @@ -26,24 +26,23 @@ class Authenticators # This class is usually not instantiated directly. Use SASL.authenticators # to reuse the default global registry. # - # By default, the registry will be empty--without any registrations. When - # +add_defaults+ is +true+, authenticators for all standard mechanisms will - # be registered. - # - def initialize(use_defaults: false) + # When +use_defaults+ is +false+, the registry will start empty. When + # +use_deprecated+ is +false+, deprecated authenticators will not be + # included with the defaults. + def initialize(use_defaults: true, use_deprecated: true) @authenticators = {} - if use_defaults - add_authenticator "Anonymous" - add_authenticator "External" - add_authenticator "OAuthBearer" - add_authenticator "Plain" - add_authenticator "Scram-SHA-1" - add_authenticator "Scram-SHA-256" - add_authenticator "XOAuth2" - add_authenticator "Login" # deprecated - add_authenticator "Cram-MD5" # deprecated - add_authenticator "Digest-MD5" # deprecated - end + return unless use_defaults + add_authenticator "Anonymous" + add_authenticator "External" + add_authenticator "OAuthBearer" + add_authenticator "Plain" + add_authenticator "Scram-SHA-1" + add_authenticator "Scram-SHA-256" + add_authenticator "XOAuth2" + return unless use_deprecated + add_authenticator "Login" # deprecated + add_authenticator "Cram-MD5" # deprecated + add_authenticator "Digest-MD5" # deprecated end # Returns the names of all registered SASL mechanisms.