Use AUTHENTICATE PLAIN instead of LOGIN
Makes imaplib use more modern AUTHENTICATE verb rather than LOGIN. The immediate benefit is that now the credentials can be non-ASCII. In the future, it may be used to add other authentication methods, such as OAuth. References: * https://datatracker.ietf.org/doc/html/rfc6855.html#page-5 * https://bugs.python.org/issue13700
This commit is contained in:
@@ -59,7 +59,10 @@ class Auth(auth.BaseAuth):
|
|||||||
if self._security == "starttls":
|
if self._security == "starttls":
|
||||||
connection.starttls(ssl.create_default_context())
|
connection.starttls(ssl.create_default_context())
|
||||||
try:
|
try:
|
||||||
connection.login(login, password)
|
connection.authenticate(
|
||||||
|
"PLAIN",
|
||||||
|
lambda _: "{0}\x00{0}\x00{1}".format(login, password).encode(),
|
||||||
|
)
|
||||||
except imaplib.IMAP4.error as e:
|
except imaplib.IMAP4.error as e:
|
||||||
logger.warning("IMAP authentication failed for user %r: %s", login, e, exc_info=False)
|
logger.warning("IMAP authentication failed for user %r: %s", login, e, exc_info=False)
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user