Skip to content

feat(imap): allow choosing SASL mechanism via login options - #312

Open
qaxi wants to merge 1 commit into
nextcloud:masterfrom
qaxi:feat/imap-login-options
Open

qaxi wants to merge 1 commit into
nextcloud:masterfrom
qaxi:feat/imap-login-options

Conversation

@qaxi

@qaxi qaxi commented Oct 22, 2026

Copy link
Copy Markdown

Fixes #153, supersedes #176, #196 and #236 (same idea, rebased on current master, single signed-off commit, with tests).

Some servers advertise mechanisms libcurl prefers but cannot complete (e.g. GSSAPI without Kerberos credentials), so login fails although PLAIN would work:

> A001 CAPABILITY
< * CAPABILITY IMAP4rev1 AUTH=PLAIN AUTH=LOGIN AUTH=NTLM AUTH=GSSAPI ...
> A002 AUTHENTICATE GSSAPI
* gss_init_sec_context() failed: No Kerberos credentials available
curl: (94) An authentication function returned an error

With curl --login-options "AUTH=PLAIN" the same login succeeds; this PR exposes that option.

An optional 7th argument is passed to CURLOPT_LOGIN_OPTIONS so the admin can pin the mechanism; existing configurations are unaffected.

Fixes #153

Supersedes #176, #196 and #236 (same idea, rebased on current master, single signed-off commit, with tests).

Changes proposed in this pull request:

  • IMAP backend: new optional 7th argument loginOptions, passed to CURLOPT_LOGIN_OPTIONS (e.g. AUTH=PLAIN, AUTH=DIGEST-MD5). Unset or empty → behaviour unchanged, so existing configurations keep working.
  • Admin settings UI: new optional "Login options" field for IMAP (appended as the 7th field, matching the argument position); rebuilt js/ assets.
  • Unit tests for the IMAP backend (tests/unit/IMAPTest.php); curl execution moved to a small executeCurl() method so it can be stubbed, the same pattern as WebDavAuth::fetchUrl().
  • README: documented the new parameter.

Tested locally: composer lint, composer cs:check, unit (46) and integration (17) tests on Nextcloud 32 / PHP 8.3, npm ci && npm run build on Node 24 (no further asset changes).

Suggested changelog line: Add optional login options (e.g. AUTH=DIGEST-MD5) for IMAP backend

Assisted-by: Claude Opus 5.5 noreply@anthropic.com
Signed-off-by: Petr Klima qaxi@seznam.cz

Some IMAP servers advertise mechanisms (e.g. GSSAPI) that libcurl picks
first but cannot complete, so the login fails although PLAIN or
DIGEST-MD5 would work. An optional 7th argument is passed to
CURLOPT_LOGIN_OPTIONS so the admin can pin the mechanism; existing
configurations are unaffected.

Fixes nextcloud#153

AI-assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Petr Klima <qaxi@seznam.cz>
@qaxi

qaxi commented Oct 22, 2026

Copy link
Copy Markdown
Author

Next attempt :-) @martinschniewind, @lazki, @damnms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMAP - can not chose compatible AUTH backend

1 participant