Skip to content

Commit bbe08db

Browse files
committed
♻️ SASL DIGEST-MD5: inherit, props, move, document
* 🚚 Move to sasl directory and SASL namespace. * 🗑️ Deprecate original constant name. * ♻️ Inherit from Authenticator base class. * ♻️ Refactor to the style used in the new ScramAuthenticator. Yes, DIGEST-MD5 is deprecated! But that also means that it is lower risk as a test-bed for refactoring a more complicated challenge/response SASL mechanism, and for developing a reasonable SASL::Authenticator base class. I improved it in several ways: * 🔒 Use SecureRandom for cnonce (not Time.now + insecure PRNG!) * ✨ Default qop=auth (as in RFC) * ✨ User can configure realm, host, service_name, service. * This allows a correct "digest-uri" for non-IMAP clients. * ✨ Enforce requirements for sparam keys (required and no-multiples). However... it's still deprecated, so maybe don't use unless you need to!
1 parent 7a2dc61 commit bbe08db

File tree

4 files changed

+467
-120
lines changed

4 files changed

+467
-120
lines changed

lib/net/imap/authenticators/digest_md5.rb

Lines changed: 0 additions & 114 deletions
This file was deleted.

lib/net/imap/sasl.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ module SASL
6565
autoload :PlainAuthenticator, "#{sasl_dir}/plain_authenticator"
6666
autoload :XOAuth2Authenticator, "#{sasl_dir}/xoauth2_authenticator"
6767

68+
autoload :DigestMD5Authenticator, "#{sasl_dir}/digest_md5_authenticator"
69+
6870
# Authenticators are all lazy loaded
6971
def self.authenticators
7072
@authenticators ||= SASL::Authenticators.new.tap do |registry|
7173
registry.add_authenticator "Plain"
7274
registry.add_authenticator "XOAuth2"
7375
registry.add_authenticator "Login", LoginAuthenticator # deprecated
7476
registry.add_authenticator "Cram-MD5", CramMD5Authenticator # deprecated
75-
registry.add_authenticator "Digest-MD5", DigestMD5Authenticator # deprecated
77+
registry.add_authenticator "Digest-MD5" # deprecated
7678
end
7779
end
7880

@@ -109,4 +111,3 @@ def initial_response?(mechanism)
109111

110112
require_relative "authenticators/login"
111113
require_relative "authenticators/cram_md5"
112-
require_relative "authenticators/digest_md5"

0 commit comments

Comments
 (0)