Multi-tenancy: sharing grants stay within the owner's tenant (MT-1, MT-3)

JMAP shareWith refuses a grantee outside the owner's tenant, or missing, with
invalidForeignKey naming the account. WebDAV ACL answers AllowedPrincipal and
IMAP SETACL answers as for an unknown account.
This commit is contained in:
2026-09-18 15:20:04 -07:00
parent cea8b1593b
commit bcf4a49325
8 changed files with 81 additions and 14 deletions
+22
View File
@@ -286,6 +286,28 @@ impl<T: SessionStream> Session<T> {
.caused_by(trc::location!())
})?;
// inbuxa: MT-3: grants stay within the owner's tenant, refused
// as if the account didn't exist
let owner_tenant = data
.server
.try_account(mailbox_id.account_id)
.await
.imap_ctx(&arguments.tag, trc::location!())?
.and_then(|owner| owner.id_tenant);
if data
.server
.try_account(acl_account_id)
.await
.imap_ctx(&arguments.tag, trc::location!())?
.is_none_or(|grantee| grantee.id_tenant != owner_tenant)
{
return Err(trc::ImapEvent::Error
.into_err()
.details("Account does not exist")
.id(arguments.tag.to_string())
.caused_by(trc::location!()));
}
// Prepare changes
let mut mailbox = current_mailbox.inner.clone();
let (op, rights) = arguments