Skip to content

Commit 34e4662

Browse files
committed
🔒 Add kwargs to deprecated +LOGIN+ and +CRAM-MD5+
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`.
1 parent 7629c21 commit 34e4662

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/net/imap/sasl/cram_md5_authenticator.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
# of cleartext and recommends TLS version 1.2 or greater be used for all
1515
# traffic. With TLS +CRAM-MD5+ is okay, but so is +PLAIN+
1616
class Net::IMAP::SASL::CramMD5Authenticator
17-
def initialize(user, password, warn_deprecation: true, **_ignored)
17+
def initialize(user = nil, pass = nil,
18+
authcid: nil, username: nil,
19+
password: nil,
20+
warn_deprecation: true,
21+
**)
1822
if warn_deprecation
1923
warn "WARNING: CRAM-MD5 mechanism is deprecated." # TODO: recommend SCRAM
2024
end
2125
require "digest/md5"
22-
@user = user
23-
@password = password
26+
@user = authcid || username || user
27+
@password = password || pass
2428
@done = false
2529
end
2630

lib/net/imap/sasl/login_authenticator.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ class Net::IMAP::SASL::LoginAuthenticator
2323
STATE_DONE = :DONE
2424
private_constant :STATE_USER, :STATE_PASSWORD, :STATE_DONE
2525

26-
def initialize(user, password, warn_deprecation: true, **_ignored)
26+
def initialize(user = nil, pass = nil,
27+
authcid: nil, username: nil,
28+
password: nil,
29+
warn_deprecation: true,
30+
**)
2731
if warn_deprecation
2832
warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead."
2933
end
30-
@user = user
31-
@password = password
34+
@user = authcid || username || user
35+
@password = password || pass
3236
@state = STATE_USER
3337
end
3438

0 commit comments

Comments
 (0)