aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-08-09 20:38:30 +0200
committerGuilhem Moulin <guilhem@fripost.org>2015-08-09 20:38:30 +0200
commitb1985240f59a22b27824c9fdcb79998a1c7c0396 (patch)
tree348ea8c603ec3c39a742c2cee9db892e21cd9187 /lib
parenta9071cd1c10bcf3a2203a28cdbdf0a26b4db8641 (diff)
Add support for SASL-IR (RFC 4959) to save a round-trip in AUTHENTICATE commands.
Diffstat (limited to 'lib')
-rw-r--r--lib/Net/IMAP/Sync.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm
index 4a9d431..85ca487 100644
--- a/lib/Net/IMAP/Sync.pm
+++ b/lib/Net/IMAP/Sync.pm
@@ -347,9 +347,13 @@ sub new($%) {
elsif ($mech eq 'PLAIN') {
require 'MIME/Base64.pm';
$self->fail("Missing option $_") foreach grep {!defined $self->{$_}} qw/username password/;
- $command = "AUTHENTICATE $mech";
my $credentials = MIME::Base64::encode_base64("\x00".$username."\x00".$password, '');
- $callback = sub($) {return $credentials};
+ $command = "AUTHENTICATE $mech";
+ if ($self->_capable('SASL-IR')) { # RFC 4959 SASL-IR
+ $command .= " $credentials";
+ } else {
+ $callback = sub($) {return $credentials};
+ }
}
else {
$self->fail("Unsupported authentication mechanism: $mech");