8000 ✨ Add very basic SASL-IR support to #authenticate [🚧 WIP] · ruby/net-imap@a6d81a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6d81a7

Browse files
committed
✨ Add very basic SASL-IR support to #authenticate [🚧 WIP]
WIP: No tests. And I'd prefer that it works automatically (by reading cached capabilities).
1 parent 2ea4086 commit a6d81a7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/net/imap.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,17 @@ def starttls(options = {}, verify = true)
10371037
# imap.login username, password
10381038
# end
10391039
#
1040-
def authenticate(mechanism, ...)
1041-
authenticator = self.class.authenticator(mechanism, ...)
1042-
send_command("AUTHENTICATE", mechanism) do |resp|
1040+
def authenticate(mechanism, *creds, sasl_ir: false, **props, &callback)
1041+
authenticator = self.class.authenticator(mechanism,
1042+
*creds, **props, &callback)
1043+
cmdargs = ["AUTHENTICATE", mechanism]
1044+
if sasl_ir && sasl.respond_to?(:initial_response?) && sasl.initial_response?
1045+
data = authenticator.process(nil)
1046+
cmdargs << [data].pack("m0")
1047+
end
1048+
send_command(*cmdargs) do |resp|
10431049
if resp.instance_of?(ContinuationRequest)
1044-
data = authenticator.process(resp.data.text.unpack("m")[0])
1050+
data = authenticator.process(resp.data.text.unpack1("m"))
10451051
s = [data].pack("m0")
10461052
send_string_data(s)
10471053
put_string(CRLF)

0 commit comments

Comments
 (0)
0