Uh oh!
There was an error while loading. Please reload this page.
fix: don't abort on LOGINDISABLED when XOAUTH2 is configured - #2
Merged
Martin Zaloudek (ma-zal) merged 2 commits intoAug 25, 2026
Merged
Conversation
LOGINDISABLED (RFC 3501) only forbids the LOGIN command; SASL mechanisms advertised as AUTH=* stay available. _login() checked it before selecting the auth mechanism, so it aborted unconditionally even when an XOAUTH/XOAUTH2 token was configured. Exchange Online advertises LOGINDISABLED together with AUTH=XOAUTH2 once basic auth is disabled for a mailbox, which made every OAuth-based IMAP connection fail with "Logging in is disabled on this server". The check now runs inside the LOGIN branch, so clients that can only use LOGIN still fail before any credentials reach the wire. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
thomashampl
approved these changes
Aug 25, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes OAuth-based IMAP authentication against servers that advertise LOGINDISABLED (notably Exchange Online) by ensuring LOGINDISABLED only blocks the LOGIN command, not SASL AUTHENTICATE mechanisms like XOAUTH/XOAUTH2.
Changes:
- Move the
LOGINDISABLEDcheck into theLOGIN(user/password) branch so XOAUTH/XOAUTH2 can still be attempted when available. - Add regression tests covering (1) XOAUTH2 success despite
LOGINDISABLEDand (2)LOGINrefusal with no credentials sent. - Bump package version to
0.8.23and add a fork-specificCHANGELOG.mdentry documenting the fix.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/Connection.js | Adjusts _login() flow so LOGINDISABLED only blocks LOGIN, not XOAUTH/XOAUTH2 AUTHENTICATE. |
test/test-connection-logindisabled-xoauth2.js | New test ensuring XOAUTH2 proceeds and reaches ready even when LOGINDISABLED is advertised. |
test/test-connection-logindisabled-login.js | New test ensuring LOGIN is blocked early and credentials are not sent when LOGINDISABLED is advertised. |
package.json | Version bump to 0.8.23. |
CHANGELOG.md | Adds fork changelog entry documenting the behavior change and references. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LOGINDISABLED(RFC 3501 §6.2.3) only forbids theLOGINcommand — SASL mechanisms advertised asAUTH=*stay available. But_login()checkedLOGINDISABLEDbefore selecting the auth mechanism, so it aborted unconditionally, even when an XOAUTH/XOAUTH2 token was configured and the server advertisedAUTH=XOAUTH2.This broke every OAuth-based IMAP connection to Exchange Online. Microsoft has permanently disabled Basic authentication for IMAP in all tenants; such mailboxes answer
CAPABILITYwithLOGINDISABLEDand withoutAUTH=PLAIN, leavingAUTH=XOAUTH2as the only usable mechanism. Captured by the Microsoft Remote Connectivity Analyzer againstoutlook.office365.com:993, where the mailbox itself is healthy:Behaviour with
new Imap({ xoauth2: '<token>', host: 'outlook.office365.com', port: 993, tls: true })against that server:CAPABILITYAUTHENTICATE XOAUTH2 <token>error:Logging in is disabled on this serverreadyThe check now runs inside the
LOGINbranch, so a client that can only useLOGINstill fails early and never puts credentials on the wire. TheSTARTTLS/autotls: 'required'decision above it is unchanged.Two tests added:
test-connection-logindisabled-xoauth2.js(XOAUTH2 succeeds despiteLOGINDISABLED; verified to fail without this fix) andtest-connection-logindisabled-login.js(LOGINstill refused, no credentials sent).https://make.atlassian.net/browse/IEN-16426
Written by 🤖 Claude Code AI, reviewed by Martin Zaloudek (@ma-zal)