Lock accounts: keep receiving mail, no sign-in, hand to delegates
A locked account can't sign in (it fails as a wrong password does), its sessions end on every node, refresh tokens stop working, and its Sieve scripts forward and reply to nothing. Mail keeps arriving. Delegates get real ACL grants on the account's mailboxes, calendars, address books and files at read, organize or full, with the rights they replaced restored on unlock. Folders made later are granted after the create and in a daily sweep. Organize delegates can't destroy; send-as needs organize or full. The JMAP session marks delegated accounts in urn:inbuxa:jmap. New inbuxa:AccountLock object with get/set, permissions 665-668, and a Compliance > Locked Accounts entry in the schema. Lock, unlock and delegate changes need a reason and are audited; delegate access and writes are audited too (audit-hold-lock spec AL-1 to AL-12).
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use ahash::AHashMap;
|
||||
@@ -198,6 +200,13 @@ impl<T: SessionStream> SessionData<T> {
|
||||
.access_token(self.account_id)
|
||||
.await
|
||||
.and_then(|inner| {
|
||||
// inbuxa: AL-3: a session opened before its account was
|
||||
// locked is refused from its next command
|
||||
if inner.is_locked() {
|
||||
return Err(trc::AuthEvent::Failed
|
||||
.into_err()
|
||||
.details("Account is locked"));
|
||||
}
|
||||
AccessToken::renew(inner, self.access_token.credential_id(), self.remote_addr)
|
||||
})
|
||||
.caused_by(trc::location!())
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
@@ -141,6 +143,14 @@ impl<T: SessionStream> SessionData<T> {
|
||||
.await
|
||||
.imap_ctx(&arguments.tag, trc::location!())?;
|
||||
|
||||
// inbuxa: AL-7: a folder a delegate makes in a locked account gets
|
||||
// the lock's grants, so the delegate can see it
|
||||
if params.account_id != self.account_id
|
||||
&& let Err(err) = email::inbuxa_lock::reconcile(&self.server, params.account_id).await
|
||||
{
|
||||
trc::error!(err.details("Failed to grant a lock's delegates on a new folder"));
|
||||
}
|
||||
|
||||
trc::event!(
|
||||
Imap(trc::ImapEvent::CreateMailbox),
|
||||
SpanId = self.session_id,
|
||||
|
||||
@@ -45,14 +45,22 @@ impl<T: SessionStream> Session<T> {
|
||||
let (data, mailbox) = self.state.select_data();
|
||||
|
||||
// Validate ACL
|
||||
if !data
|
||||
.check_mailbox_acl(
|
||||
mailbox.id.account_id,
|
||||
mailbox.id.mailbox_id,
|
||||
Acl::RemoveItems,
|
||||
)
|
||||
// inbuxa: AL-6: a delegate below full may move mail, never delete it
|
||||
let may_destroy = data
|
||||
.refresh_access_token()
|
||||
.await
|
||||
.imap_ctx(&request.tag, trc::location!())?
|
||||
.delegation(mailbox.id.account_id)
|
||||
.is_none_or(|delegation| delegation.access.may_destroy());
|
||||
if !may_destroy
|
||||
|| !data
|
||||
.check_mailbox_acl(
|
||||
mailbox.id.account_id,
|
||||
mailbox.id.mailbox_id,
|
||||
Acl::RemoveItems,
|
||||
)
|
||||
.await
|
||||
.imap_ctx(&request.tag, trc::location!())?
|
||||
{
|
||||
return Err(trc::ImapEvent::Error
|
||||
.into_err()
|
||||
@@ -143,6 +151,16 @@ impl<T: SessionStream> SessionData<T> {
|
||||
) -> trc::Result<Option<u32>> {
|
||||
// Obtain message ids
|
||||
let account_id = mailbox.id.account_id;
|
||||
// inbuxa: AL-6: nothing is deleted for a delegate below full (CLOSE
|
||||
// expunges quietly, so it deletes nothing, quietly)
|
||||
if self
|
||||
.refresh_access_token()
|
||||
.await?
|
||||
.delegation(account_id)
|
||||
.is_some_and(|delegation| !delegation.access.may_destroy())
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
let mut deleted_ids = RoaringBitmap::from_iter(
|
||||
self.server
|
||||
.get_cached_messages(account_id)
|
||||
|
||||
Reference in New Issue
Block a user