Merge pull request #1931 from pbiering/support-issue-1929
re-add IMAP/LOGIN as fallback replaced with 3.5.0
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
## 3.5.10.dev
|
## 3.5.10.dev
|
||||||
* Improve: logging of broken calendar items during PUT
|
* Improve: logging of broken calendar items during PUT
|
||||||
* Add: logging of broken contact items during PUT
|
* Add: logging of broken contact items during PUT
|
||||||
|
* Extend: [auth] imap: add fallback support for LOGIN towards remote IMAP server (replaced in 3.5.0)
|
||||||
|
|
||||||
## 3.5.9
|
## 3.5.9
|
||||||
* Extend: [auth] add support for type http_remote_user
|
* Extend: [auth] add support for type http_remote_user
|
||||||
|
|||||||
@@ -64,10 +64,18 @@ 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.authenticate(
|
if "AUTH=PLAIN" in connection.capabilities:
|
||||||
"PLAIN",
|
logger.debug("IMAP authentication PLAIN selected for user %r via %s:%d (security: %s)", login, self._host, self._port, self._security)
|
||||||
lambda _: "{0}\x00{0}\x00{1}".format(login, password).encode(),
|
connection.authenticate(
|
||||||
)
|
"PLAIN",
|
||||||
|
lambda _: "{0}\x00{0}\x00{1}".format(login, password).encode(),
|
||||||
|
)
|
||||||
|
elif "AUTH=LOGIN" in connection.capabilities:
|
||||||
|
logger.debug("IMAP authentication LOGIN selected for user %r via %s:%d (security: %s)", login, self._host, self._port, self._security)
|
||||||
|
connection.login(login, password)
|
||||||
|
else:
|
||||||
|
logger.error("IMAP server is neither supporting AUTH=PLAIN or AUTH=LOGIN: %s:%d (security: %s)", self._host, self._port, self._security)
|
||||||
|
return ""
|
||||||
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