Skip to content

Commit

Permalink
✨ Add very basic SASL-IR support to #authenticate
Browse files Browse the repository at this point in the history
WIP: No tests.  And I'd rather handle this automatically (by reading
cached capabilities).
  • Loading branch information
nevans committed Dec 21, 2022
1 parent c626c4c commit 7ac80f0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,17 @@ def starttls(options = {}, verify = true)
#
# See +Net::IMAP::Authenticators+ for more information on plugging in your
# own authenticator.
def authenticate(auth_type, ...)
authenticator = self.class.authenticator(auth_type, ...)
send_command("AUTHENTICATE", auth_type) do |resp|
def authenticate(auth_type, *creds, sasl_ir: false, **props, &callback)
authenticator = self.class.authenticator(auth_type,
*creds, **props, &callback)
cmdargs = ["AUTHENTICATE", auth_type]
if sasl_ir && sasl.respond_to?(:initial_response?) && sasl.initial_response?
data = authenticator.process(nil)
cmdargs << [data].pack("m0")
end
send_command(*cmdargs) do |resp|
if resp.instance_of?(ContinuationRequest)
data = authenticator.process(resp.data.text.unpack("m")[0])
data = authenticator.process(resp.data.text.unpack1("m"))
s = [data].pack("m0")
send_string_data(s)
put_string(CRLF)
Expand Down

0 comments on commit 7ac80f0

Please sign in to comment.