Shared mailboxes: full members manage the filters, sorting only (#643) #646

Merged
jcoffey-dev merged 1 commits from fix/643-shared-mailbox-filters into main 2026-11-25 21:03:19 +00:00
Owner

Fixes #643

A shared mailbox's full members can now manage its filters, the way its owner could. Read and organize members can't, as before.

What changes

  • Access. A member whose shared-mailbox delegation is full may use SieveScript/get, /query, /set (with onSuccessActivateScript and onSuccessDeactivateScript) and /validate on the shared mailbox. Read and organize members still get forbidden. Owners and Impersonate holders are unchanged. Locked accounts (kind: lock) are unchanged.
  • Script blobs. The webmail uploads a script with /upload/{accountId} and then calls SieveScript/set. A full member may now upload to the shared mailbox (charged to its upload quota), read back what was uploaded there, and download its scripts. Nothing else is widened: Blob/upload, other collections' blobs and other delegation kinds keep their current rules.
  • Sort only, unless an administrator saves it. The server reads the compiled script's instructions, not its require line. The actions that send or answer mail are redirect (with or without :copy), vacation, notify and reject/ereject, each compared with its arguments (address, reply text and :days, method, reason). When a full member who isn't an administrator saves a script:
    • a new script with any of them is refused;
    • an update may keep the ones already in the stored script and may remove them, but may not add one or change one. A member can edit the other rules of a script an administrator gave a forward, and can delete that forward, but can't point it somewhere else;
    • the refusal is a forbidden SetError: "Forwarding and automatic replies on a shared mailbox can only be saved by an administrator." A refused create or update also skips the call's activation, so the active script stays as it was.
  • Turning one on. A member can't activate a script that holds any of those actions unless it is already the active one (onSuccessActivateScript, or isActive: true on an update). The refusal is a forbidden SetError in notUpdated for that script: "Filters that forward or answer mail on a shared mailbox can only be turned on by an administrator." Turning it off and deleting it are allowed. An administrator may save and activate any script.
  • Audit (AU-3). On a shared mailbox, every create, update and destroy of a script by anyone but the account itself is recorded as recorded records other set methods, with the actor and the shared mailbox. Activating and deactivating a script get a record of their own (details "Activated" or "Deactivated", an isActive change). Each record is written before the change, and if it can't be written, nothing is changed.
  • Session. urn:ietf:params:jmap:sieve is advertised on a secondary account only when the session can manage its scripts: a member, an administrator, or a full member of a shared mailbox. Read and organize members, and accounts that only share folders, no longer see a Filters capability they can't use.

Sieve::sends_mail() and Sieve::sending_actions() are added to the vendored sieve-rs (noted in vendor/sieve-rs/VENDORED.md), since the instruction list is crate-private. No untrusted Sieve function sends mail, so those four instructions (and the vacation test that holds :days, :addresses and :handle) are the whole list.

The server doesn't record who last saved a script, so the activation rule doesn't ask: a member can't turn on any script with those actions, even one an administrator saved and left off.

Files

  • vendor/sieve-rs/src/lib.rs, vendor/sieve-rs/VENDORED.md: Sieve::sends_mail()
  • crates/common/src/auth/access_token.rs: is_full_shared_mailbox_delegate, manages_sieve
  • crates/jmap/src/api/auth.rs, crates/jmap/src/api/request.rs: assert_manages_sieve on the four Sieve methods; SieveScript/set goes through the new module
  • crates/jmap/src/inbuxa/shared_filters.rs (new): the audit records
  • crates/jmap/src/sieve/set.rs: the keep-or-remove check and the activation check
  • crates/jmap/src/blob/upload.rs, crates/jmap/src/blob/download.rs: script blobs for full members
  • crates/jmap/src/api/session.rs: the capability
  • crates/common/src/config/mailstore/scripts.rs: unit test for sends_mail
  • tests/src/system/account_lock.rs: shared_mailbox_filters

Tests

  • sieve_sends_mail_reads_the_instructions (crates/common): each sending action, one in a branch that may never run, a script that requires them all but uses none, and the same actions comparing equal across other edits but not with a changed address, :copy, :days or reason.
  • sending_actions_may_be_kept_or_removed (crates/jmap): the multiset rule.
  • account_lock_tests (shared_mailbox_filters):
    • The session offers filters to the full member only.
    • Read and organize members get forbidden on get, query and set, and their uploads are refused.
    • The full member validates, creates and activates a sorting script, reads it back and downloads it, and mail to the shared address is filed by it.
    • Six forwarding or reply scripts are refused on create and on update, and the active script and its blob are unchanged.
    • An administrator adds a redirect :copy to the active script. The member edits another rule with the redirect kept (saved), changes the redirect's address (refused, script unchanged) and removes the redirect (saved).
    • An administrator saves a forwarding script and leaves it off. The member can't turn it on, either way; the administrator can, and the member then turns it off and deletes it.
    • The audit log has the member's create, activate, deactivate, destroy and refused records (the refused activation too), and the administrator's.

ManageSieve stays per account, as the issue says.

Changelog

For the next version PR, under Added:

  • A shared mailbox's full members can manage its filters (SieveScript/get, query, set and validate on the shared mailbox), which may only sort: forwarding and automatic replies (redirect, vacation, notify, reject) are added, changed and turned on by an administrator, and a member may keep or remove them. Every change to a shared mailbox's filters is in the audit log, and the session offers filters only on accounts where they can be managed. (#643)
Fixes #643 A shared mailbox's full members can now manage its filters, the way its owner could. Read and organize members can't, as before. ## What changes - **Access.** A member whose shared-mailbox delegation is `full` may use `SieveScript/get`, `/query`, `/set` (with `onSuccessActivateScript` and `onSuccessDeactivateScript`) and `/validate` on the shared mailbox. Read and organize members still get `forbidden`. Owners and `Impersonate` holders are unchanged. Locked accounts (`kind: lock`) are unchanged. - **Script blobs.** The webmail uploads a script with `/upload/{accountId}` and then calls `SieveScript/set`. A full member may now upload to the shared mailbox (charged to its upload quota), read back what was uploaded there, and download its scripts. Nothing else is widened: `Blob/upload`, other collections' blobs and other delegation kinds keep their current rules. - **Sort only, unless an administrator saves it.** The server reads the compiled script's instructions, not its `require` line. The actions that send or answer mail are `redirect` (with or without `:copy`), `vacation`, `notify` and `reject`/`ereject`, each compared with its arguments (address, reply text and `:days`, method, reason). When a full member who isn't an administrator saves a script: - a new script with any of them is refused; - an update may keep the ones already in the stored script and may remove them, but may not add one or change one. A member can edit the other rules of a script an administrator gave a forward, and can delete that forward, but can't point it somewhere else; - the refusal is a `forbidden` SetError: "Forwarding and automatic replies on a shared mailbox can only be saved by an administrator." A refused create or update also skips the call's activation, so the active script stays as it was. - **Turning one on.** A member can't activate a script that holds any of those actions unless it is already the active one (`onSuccessActivateScript`, or `isActive: true` on an update). The refusal is a `forbidden` SetError in `notUpdated` for that script: "Filters that forward or answer mail on a shared mailbox can only be turned on by an administrator." Turning it off and deleting it are allowed. An administrator may save and activate any script. - **Audit (AU-3).** On a shared mailbox, every create, update and destroy of a script by anyone but the account itself is recorded as `recorded` records other set methods, with the actor and the shared mailbox. Activating and deactivating a script get a record of their own (`details` "Activated" or "Deactivated", an `isActive` change). Each record is written before the change, and if it can't be written, nothing is changed. - **Session.** `urn:ietf:params:jmap:sieve` is advertised on a secondary account only when the session can manage its scripts: a member, an administrator, or a full member of a shared mailbox. Read and organize members, and accounts that only share folders, no longer see a Filters capability they can't use. `Sieve::sends_mail()` and `Sieve::sending_actions()` are added to the vendored sieve-rs (noted in `vendor/sieve-rs/VENDORED.md`), since the instruction list is crate-private. No untrusted Sieve function sends mail, so those four instructions (and the vacation test that holds `:days`, `:addresses` and `:handle`) are the whole list. The server doesn't record who last saved a script, so the activation rule doesn't ask: a member can't turn on any script with those actions, even one an administrator saved and left off. ## Files - `vendor/sieve-rs/src/lib.rs`, `vendor/sieve-rs/VENDORED.md`: `Sieve::sends_mail()` - `crates/common/src/auth/access_token.rs`: `is_full_shared_mailbox_delegate`, `manages_sieve` - `crates/jmap/src/api/auth.rs`, `crates/jmap/src/api/request.rs`: `assert_manages_sieve` on the four Sieve methods; SieveScript/set goes through the new module - `crates/jmap/src/inbuxa/shared_filters.rs` (new): the audit records - `crates/jmap/src/sieve/set.rs`: the keep-or-remove check and the activation check - `crates/jmap/src/blob/upload.rs`, `crates/jmap/src/blob/download.rs`: script blobs for full members - `crates/jmap/src/api/session.rs`: the capability - `crates/common/src/config/mailstore/scripts.rs`: unit test for `sends_mail` - `tests/src/system/account_lock.rs`: `shared_mailbox_filters` ## Tests - `sieve_sends_mail_reads_the_instructions` (crates/common): each sending action, one in a branch that may never run, a script that requires them all but uses none, and the same actions comparing equal across other edits but not with a changed address, `:copy`, `:days` or reason. - `sending_actions_may_be_kept_or_removed` (crates/jmap): the multiset rule. - `account_lock_tests` (`shared_mailbox_filters`): - The session offers filters to the full member only. - Read and organize members get `forbidden` on get, query and set, and their uploads are refused. - The full member validates, creates and activates a sorting script, reads it back and downloads it, and mail to the shared address is filed by it. - Six forwarding or reply scripts are refused on create and on update, and the active script and its blob are unchanged. - An administrator adds a `redirect :copy` to the active script. The member edits another rule with the redirect kept (saved), changes the redirect's address (refused, script unchanged) and removes the redirect (saved). - An administrator saves a forwarding script and leaves it off. The member can't turn it on, either way; the administrator can, and the member then turns it off and deletes it. - The audit log has the member's create, activate, deactivate, destroy and refused records (the refused activation too), and the administrator's. ManageSieve stays per account, as the issue says. ## Changelog For the next version PR, under Added: - A shared mailbox's full members can manage its filters (SieveScript/get, query, set and validate on the shared mailbox), which may only sort: forwarding and automatic replies (redirect, vacation, notify, reject) are added, changed and turned on by an administrator, and a member may keep or remove them. Every change to a shared mailbox's filters is in the audit log, and the session offers filters only on accounts where they can be managed. (#643)
jcoffey-dev added 1 commit 2026-11-25 20:47:33 +00:00
Shared mailboxes: full members manage the filters, sorting only (#643)
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 14m28s
905ea84634
A member whose shared-mailbox delegation is full may use SieveScript/get,
query, set and validate on the shared mailbox, upload the script there
and download it. Read and organize members still get forbidden.

When such a member isn't an administrator, the compiled script's actions
that send or answer mail (redirect, vacation, notify, reject) may be
kept or removed but not added or changed, and a script holding them
can't be turned on by the member. Every change to a shared mailbox's
scripts by anyone but the account itself is recorded in the audit log,
activations included. The session offers the Sieve capability on a
secondary account only where its scripts can be managed.
jcoffey-dev merged commit 4b75574bf7 into main 2026-11-25 21:03:19 +00:00
jcoffey-dev deleted branch fix/643-shared-mailbox-filters 2026-11-25 21:03:20 +00:00
Sign in to join this conversation.