IMAP: server response codes are dropped, so a temporary outage looks like a rejected sign-in

Open
#665 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
swift

Research direction

Start with AuthenticateHandler and the IMAPError.authenticationFailed and IMAPError.commandFailed cases, where tagged NO replies currently keep only their text. Carry the bracketed response code on those errors, then check that UNAVAILABLE, AUTHENTICATIONFAILED, EXPIRED and ALERT are handled as the issue describes. Done means the code survives to the error and the sign-in failure is classified from it, which needs a test for each code.

Written by the indexing model from the issue text.

Description

Summary

When a command fails, the IMAP handlers keep the human-readable text of the server's reply and drop the response code in square brackets. For sign-in that code is what tells a wrong credential from a server that is temporarily down.

(Found by reading the code.)

Details

With the work for #535, AuthenticateHandler turns every tagged NO into IMAPError.authenticationFailed carrying the text only. NO [UNAVAILABLE] … and NO [AUTHENTICATIONFAILED] … produce the same error. The other handlers do the same with commandFailed.

This starts to matter as soon as something acts on a rejected sign-in, for example by refreshing the token or asking the user to sign in again.

Expected behavior

  • The response code is kept on the error.
  • UNAVAILABLE is treated as temporary: try again later, don't touch the credential.
  • AUTHENTICATIONFAILED and EXPIRED are treated as a credential problem.
  • ALERT text reaches the user.

Suggested fix

Carry the response code on IMAPError.authenticationFailed and IMAPError.commandFailed, and classify the sign-in failure from it.

References

  • RFC 5530, section 3, UNAVAILABLE: "Temporary failure because a subsystem is down."
  • RFC 5530, section 3, AUTHENTICATIONFAILED: "when a client sees AUTHENTICATIONFAILED, it knows that the problem wasn't, e.g., UNAVAILABLE, so there's no point in trying the same login/password again later."
  • RFC 5530, section 3, EXPIRED: "Either authentication succeeded or the server no longer had the necessary data; either way, access is no longer permitted using that passphrase."
  • RFC 3501, section 7.1, ALERT: "The human-readable text contains a special alert that MUST be presented to the user in a fashion that calls the user's attention to the message."

In thunderbird-android

Links are pinned to ac1f0e8.

Dominant language
Swift
Stars
1.3k
Forks
51
Avg merge
1d 7h
Merged PRs (30d)
33

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thunderbird/thunderbird-ios

All issues in thunderbird/thunderbird-ios

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.