Skip to content

fix(mail): Open, save and enable disabled accounts without a 403 - #42

Merged
s-aga-r merged 1 commit into
developfrom
fix/disabled-account-credentials
Oct 28, 2026
Merged

s-aga-r merged 1 commit into
developfrom
fix/disabled-account-credentials

Conversation

@s-aga-r

@s-aga-r s-aga-r commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Suite Cloud reads an account's app passwords and API keys by logging in as the account (master-user login). The suite-disabled role allows only emailReceive, so Stalwart refuses that login with a 403. A disabled account failed in these places:

  • Opening the form in Desk logged "[Suite Cloud] Credential lookup failed" (refresh() on getdoc).
  • Each save failed when the API key list was empty, which is the usual case. Enabling the account again also failed.
  • Rotating the app password or API key failed.
  • Edits to credentials failed with a 403.

Changes in account_credentials.py:

  • refresh(): a disabled account opens on the credentials stored on the site. It does not ask the cluster.
  • validate(): while the cluster has the account disabled, the credentials are not loaded or changed. Edits stop with "Enable the account before changing its app passwords" (or "API keys"). Other fields save, and the account can be enabled.
  • rotate_site_login(): stops with the same message on a disabled account.
  • row_by_id(): does not load from the cluster for a disabled account.

The fake Stalwart refuses the session for an account whose custom roles grant nothing beyond emailReceive, as the real server does.

Relation to #40

#40 fixes only the validate() load on the save that enables an account. With #40 applied, opening a disabled account still logs the 403 above. This PR also covers that case. Both PRs change validate() and the fake Stalwart, so the second one to merge needs a small merge.

Test plan

  • New test_a_disabled_account_keeps_its_mirrored_credentials covers opening, editing, rotating, saving and enabling a disabled account. Before the fix it failed with the reported 403.
  • The full suite_cloud suite passes (416 tests, 2 skipped).
  • ruff check and ruff format --check pass.

Suite Cloud reads an account's app passwords and API keys by logging in
as the account. The disabled role allows only receiving mail, so Stalwart
refuses that login. Opening the form, saving, enabling or rotating a
disabled account failed with a 403.

A disabled account now shows the credentials stored on the site. Its
saves leave them as they are. Changes and rotations ask to enable the
account first. The fake Stalwart refuses the login for a receive-only
account, as the real one does.
@s-aga-r
s-aga-r merged commit 9a53c09 into develop Oct 28, 2026
7 checks passed
@s-aga-r
s-aga-r deleted the fix/disabled-account-credentials branch October 28, 2026 13:00
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.

1 participant