From 34e466288734f44239a4e9ec8f0db4a64a140e91 Mon Sep 17 00:00:00 2001 From: nick evans Date: Sat, 14 Oct 2023 18:30:31 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20Add=20kwargs=20to=20deprecated?= =?UTF-8?q?=20+LOGIN+=20and=20+CRAM-MD5+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are added to give _all_ mechanisms the same basic argument semantics. If it were just for `Net::IMAP`, I'd say it's not worth it. However, to make this `SASL` implementation fully compatible with others—such as `net-smtp`. --- lib/net/imap/sasl/cram_md5_authenticator.rb | 10 +++++++--- lib/net/imap/sasl/login_authenticator.rb | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/net/imap/sasl/cram_md5_authenticator.rb b/lib/net/imap/sasl/cram_md5_authenticator.rb index 3aac7b35..d5648515 100644 --- a/lib/net/imap/sasl/cram_md5_authenticator.rb +++ b/lib/net/imap/sasl/cram_md5_authenticator.rb @@ -14,13 +14,17 @@ # of cleartext and recommends TLS version 1.2 or greater be used for all # traffic. With TLS +CRAM-MD5+ is okay, but so is +PLAIN+ class Net::IMAP::SASL::CramMD5Authenticator - def initialize(user, password, warn_deprecation: true, **_ignored) + def initialize(user = nil, pass = nil, + authcid: nil, username: nil, + password: nil, + warn_deprecation: true, + **) if warn_deprecation warn "WARNING: CRAM-MD5 mechanism is deprecated." # TODO: recommend SCRAM end require "digest/md5" - @user = user - @password = password + @user = authcid || username || user + @password = password || pass @done = false end diff --git a/lib/net/imap/sasl/login_authenticator.rb b/lib/net/imap/sasl/login_authenticator.rb index 5132a09e..81201f66 100644 --- a/lib/net/imap/sasl/login_authenticator.rb +++ b/lib/net/imap/sasl/login_authenticator.rb @@ -23,12 +23,16 @@ class Net::IMAP::SASL::LoginAuthenticator STATE_DONE = :DONE private_constant :STATE_USER, :STATE_PASSWORD, :STATE_DONE - def initialize(user, password, warn_deprecation: true, **_ignored) + def initialize(user = nil, pass = nil, + authcid: nil, username: nil, + password: nil, + warn_deprecation: true, + **) if warn_deprecation warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead." end - @user = user - @password = password + @user = authcid || username || user + @password = password || pass @state = STATE_USER end