Add support for AUTH=PLAIN to imap.el

* lisp/net/imap.el (imap-authenticators): Add 'plain' to the
list.
(imap-authenticator-alist): Add 'imap-plain-p' and
'imap-plain-auth'.
(imap-plain-p): New function, detects AUTH=PLAIN support.
(imap-plain-auth): Perform the AUTH=PLAIN authentication.

* doc/misc/gnus.texi (Mail Source Specifiers): Add 'plain'.
(Conformity): Add reference to RFC 4616.

* etc/NEWS: Announce the support.
This commit is contained in:
Robert Pluim 2025-07-28 10:46:30 +02:00
parent 93dff95463
commit 45a5fae991
3 changed files with 31 additions and 3 deletions

View file

@ -15357,7 +15357,7 @@ symbols in @code{imap-stream-alist}. Right now, this means
Which authenticator to use for authenticating to the server, this is
one of the symbols in @code{imap-authenticator-alist}. Right now,
this means @samp{gssapi}, @samp{kerberos4}, @samp{digest-md5},
@samp{cram-md5}, @samp{anonymous} or the default @samp{login}.
@samp{cram-md5}, @samp{plain}, @samp{anonymous} or the default @samp{login}.
@item :program
When using the @samp{shell} :stream, the contents of this variable is
@ -27096,14 +27096,15 @@ Gnus supports both encoding and decoding.
@item S/MIME---RFC 2633
RFC 2633 describes the @acronym{S/MIME} format.
@item IMAP---RFC 1730/2060, RFC 2195, RFC 2086, RFC 2359, RFC 2595, RFC 1731
@item IMAP---RFC 1730/2060, RFC 2195/4616, RFC 2086, RFC 2359, RFC 2595, RFC 1731
RFC 1730 is @acronym{IMAP} version 4, updated somewhat by RFC 2060
(@acronym{IMAP} 4 revision 1). RFC 2195 describes CRAM-MD5
authentication for @acronym{IMAP}. RFC 2086 describes access control
lists (ACLs) for @acronym{IMAP}. RFC 2359 describes a @acronym{IMAP}
protocol enhancement. RFC 2595 describes the proper @acronym{TLS}
integration (STARTTLS) with @acronym{IMAP}. RFC 1731 describes the
GSSAPI/Kerberos4 mechanisms for @acronym{IMAP}.
GSSAPI/Kerberos4 mechanisms for @acronym{IMAP}. RFC 4616 describes
AUTH=PLAIN authentication for @acronym{IMAP}.
@end table

View file

@ -1336,6 +1336,14 @@ This contains the list of regular expressions used to match "Re:" and
international variants of it when modifying the Subject field in
replies.
** Imap
---
*** 'imap-authenticate' can now use PLAIN authentication.
"AUTH=PLAIN" support is auto-enabled if the IMAP server supports it. Pass
a specific authentication type to 'imap-authenticate' or remove 'plain'
from 'imap-authenticators' if you do not wish to use "AUTH=PLAIN".
** Rmail
+++

View file

@ -275,6 +275,7 @@ stream.")
digest-md5
cram-md5
;;sasl
plain
login
anonymous)
"Priority of authenticators to consider when authenticating to server.")
@ -284,6 +285,7 @@ stream.")
(kerberos4 imap-kerberos4-auth-p imap-kerberos4-auth)
(sasl imap-sasl-auth-p imap-sasl-auth)
(cram-md5 imap-cram-md5-p imap-cram-md5-auth)
(plain imap-plain-p imap-plain-auth)
(login imap-login-p imap-login-auth)
(anonymous imap-anonymous-p imap-anonymous-auth)
(digest-md5 imap-digest-md5-p imap-digest-md5-auth))
@ -853,6 +855,23 @@ t if it successfully authenticates, nil otherwise."
(imap-quote-specials passwd)
"\""))))))
(defun imap-plain-p (buffer)
(imap-capability 'AUTH=PLAIN buffer))
(defun imap-plain-auth (buffer)
"Login to server using the AUTH=PLAIN command."
(message "imap: PLAIN authentication...")
(imap-interactive-login
buffer
(lambda (user passwd)
(imap-ok-p
(imap-send-command-wait
(concat "AUTHENTICATE PLAIN "
(base64-encode-string
(format "\000%s\000%s"
(imap-quote-specials user)
(imap-quote-specials passwd)))))))))
(defun imap-anonymous-p (_buffer)
t)