Skip to content

Commit

Permalink
🔒 Add kwargs to deprecated +LOGIN+ and +CRAM-MD5+
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
nevans committed Oct 19, 2023
1 parent 7629c21 commit 34e4662
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/net/imap/sasl/cram_md5_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions lib/net/imap/sasl/login_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 34e4662

Please sign in to comment.