Skip to content

Commit

Permalink
🐛 Fix authenticate using Symbol mechanism name
Browse files Browse the repository at this point in the history
Based on `net-smtp`, I had added the ability to use symbols to lookup
authenticator.  But it had two issues: 1) dealing with dashes vs
underscores, and 2) sending the mechanism name using flag syntax.  This
fixes both issues.
  • Loading branch information
nevans committed Oct 1, 2023
1 parent 965f9a3 commit c3f7e7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ def starttls(**options)
# completes. If the TaggedResponse to #authenticate includes updated
# capabilities, they will be cached.
def authenticate(mechanism, *creds, sasl_ir: true, **props, &callback)
mechanism = mechanism.to_s.tr("_", "-").upcase
authenticator = SASL.authenticator(mechanism, *creds, **props, &callback)
cmdargs = ["AUTHENTICATE", mechanism]
if sasl_ir && capable?("SASL-IR") && auth_capable?(mechanism) &&
Expand Down
2 changes: 1 addition & 1 deletion test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ def test_id
server.state.authenticate(server.config.user)
cmd.done_ok
end
imap.authenticate("DIGEST-MD5", "test_user", "test-password",
imap.authenticate(:digest_md5, "test_user", "test-password",
warn_deprecation: false)
cmd, cont1, cont2 = 3.times.map { server.commands.pop }
assert_equal %w[AUTHENTICATE DIGEST-MD5], [cmd.name, *cmd.args]
Expand Down

0 comments on commit c3f7e7c

Please sign in to comment.