Implement user suspension #876

Merged
nex merged 23 commits from nex/user-suspension into main 2025-06-29 15:38:02 +00:00
Owner

This PR implements user suspension, part of the 1.13 matrix spec.

Specifically, the set of specific forbidden actions are implemented, rather than explicitly permitted. Room creation is additionally forbidden, despite it being missing from the spec defs, because there's no legitimate reason to create rooms you cannot send nor invite to.

This PR implements [user suspension](https://spec.matrix.org/v1.15/client-server-api/#account-suspension), part of the 1.13 matrix spec. Specifically, the set of specific forbidden actions are implemented, rather than explicitly permitted. Room creation is additionally forbidden, despite it being missing from the spec defs, because there's no legitimate reason to create rooms you cannot send nor invite to.
nex added this to the 0.5.0 milestone 2025-06-28 20:30:35 +00:00
nex added the
Database
Enhancement
Matrix/Administration
Matrix/Client
Matrix/Auth
labels 2025-06-28 20:30:35 +00:00
nex added 12 commits 2025-06-28 20:30:35 +00:00
feat: Prevent suspended users creating new rooms
Some checks failed
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 38s
Checks / Rust / Format (push) Successful in 42s
Checks / Rust / Clippy (push) Failing after 3m13s
Checks / Rust / Cargo Test (push) Successful in 4m13s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 9m59s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 19m30s
Release Docker Image / merge (push) Successful in 31s
424b2b039b
fix: Inappropriate empty check
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 1s
Checks / Prefligit / prefligit (push) Successful in 28s
Checks / Rust / Format (push) Successful in 47s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
Checks / Rust / Cargo Test (push) Has been cancelled
Checks / Rust / Clippy (push) Has been cancelled
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
762f9e59f0
I once again, assumed `true` is actually `false`.
feat: Do not allow suspending admin users
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 40s
Checks / Rust / Format (push) Successful in 55s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Checks / Rust / Clippy (push) Has been cancelled
Checks / Rust / Cargo Test (push) Has been cancelled
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
712acc6cb1
style: Remove unneeded statements (clippy)
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 3s
Checks / Prefligit / prefligit (push) Successful in 25s
Checks / Rust / Format (push) Successful in 45s
Checks / Rust / Cargo Test (push) Successful in 3m40s
Checks / Rust / Clippy (push) Successful in 4m10s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
13ba3f278f
feat: Forbid suspended users from sending state events
Some checks failed
Release Docker Image / define-variables (push) Successful in 3s
Checks / Prefligit / prefligit (push) Successful in 34s
Checks / Rust / Format (push) Successful in 49s
Checks / Rust / Clippy (push) Successful in 4m15s
Checks / Rust / Cargo Test (push) Successful in 4m45s
Checks / Prefligit / prefligit (pull_request) Successful in 27s
Documentation / Build and Deploy Documentation (pull_request) Successful in 50s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Failing after 13m57s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Failing after 17m29s
Release Docker Image / merge (push) Has been cancelled
a6ceaa8259
requested review from Owners 2025-06-28 20:31:03 +00:00
nex added 3 commits 2025-06-28 21:43:57 +00:00
Prevents kicks, bans, unbans, and alias modification
feat: Prevent suspended users upgrading rooms
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 29s
Checks / Rust / Format (push) Successful in 39s
Checks / Prefligit / prefligit (pull_request) Successful in 27s
Documentation / Build and Deploy Documentation (pull_request) Successful in 47s
Checks / Rust / Clippy (push) Successful in 3m30s
Checks / Rust / Cargo Test (push) Successful in 4m5s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
c4ce2aa291
Author
Owner

Added some additional suspension checks:

  • Creating & Deleting aliases are forbidden
  • Changing the room visibility is forbidden
  • Banning, unbanning, and kicking users is forbidden
  • Uploading new media is forbidden
  • Upgrading rooms via /upgrade is forbidden
Added some additional suspension checks: - Creating & Deleting aliases are forbidden - Changing the room visibility is forbidden - Banning, unbanning, and kicking users is forbidden - Uploading new media is forbidden - Upgrading rooms via /upgrade is forbidden
nex added 2 commits 2025-06-28 21:53:33 +00:00
feat: Do not allow suspended users to send typing statuses
All checks were successful
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 14s
Checks / Rust / Format (push) Successful in 41s
Documentation / Build and Deploy Documentation (pull_request) Successful in 46s
Checks / Prefligit / prefligit (pull_request) Successful in 28s
Checks / Rust / Clippy (push) Successful in 3m59s
Checks / Rust / Cargo Test (push) Successful in 4m25s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 12m6s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 12m40s
Release Docker Image / merge (push) Successful in 25s
b3428c2e3d
Author
Owner

Also, suspended users can no-longer send public read receipts, or typing. I'm pretty sure this covers the basis for all "write" endpoints now.

Also, suspended users can no-longer send public read receipts, or typing. I'm pretty sure this covers the basis for all "write" endpoints now.
Jade reviewed 2025-06-28 22:05:45 +00:00
@ -143,6 +145,16 @@ impl Service {
Ok(())
}
/// Suspend account, placing it in a read-only state
Owner

Might want to use an actual struct here. In case we want to add things like time to suspensions, oh being able to send in specific rooms to communicate with admins

Might want to use an actual struct here. In case we want to add things like time to suspensions, oh being able to send in specific rooms to communicate with admins
Author
Owner

oh being able to send in specific rooms to communicate with admins

if this is a suggestion rather than a reasoning for using a struct, I think that's best suited for another PR

> oh being able to send in specific rooms to communicate with admins if this is a suggestion rather than a reasoning for using a struct, I think that's best suited for another PR
nex marked this conversation as resolved
nex added 1 commit 2025-06-29 00:52:13 +00:00
fix: Missing suspensions shouldn't error
All checks were successful
Checks / Prefligit / prefligit (push) Successful in 33s
Release Docker Image / define-variables (push) Successful in 2s
Checks / Rust / Format (push) Successful in 1m1s
Documentation / Build and Deploy Documentation (pull_request) Successful in 48s
Checks / Prefligit / prefligit (pull_request) Successful in 25s
Checks / Rust / Clippy (push) Successful in 5m0s
Checks / Rust / Cargo Test (push) Successful in 5m25s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 13m33s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 13m43s
Release Docker Image / merge (push) Successful in 27s
c6ed641dcb
Turns out copying and pasting the function
above verbatim actually introduces more
problems than it solves!
nex added 1 commit 2025-06-29 01:28:12 +00:00
fix: Failing open on database errors
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 12s
Checks / Prefligit / prefligit (push) Successful in 29s
Checks / Prefligit / prefligit (pull_request) Successful in 17s
Checks / Rust / Format (push) Successful in 45s
Documentation / Build and Deploy Documentation (pull_request) Successful in 50s
Checks / Rust / Clippy (push) Has been cancelled
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Checks / Rust / Cargo Test (push) Has been cancelled
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
a67d9eb76a
oops
nex added 1 commit 2025-06-29 01:30:58 +00:00
style: Remove unnecessary imports (clippy)
All checks were successful
Release Docker Image / define-variables (push) Successful in 8s
Checks / Prefligit / prefligit (push) Successful in 27s
Checks / Rust / Format (push) Successful in 35s
Checks / Prefligit / prefligit (pull_request) Successful in 14s
Documentation / Build and Deploy Documentation (pull_request) Successful in 47s
Checks / Rust / Clippy (push) Successful in 2m59s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 10m23s
Checks / Rust / Cargo Test (push) Successful in 3m7s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 19m46s
Release Docker Image / merge (push) Successful in 19s
db07480aec
Jade added 1 commit 2025-06-29 14:07:44 +00:00
feat: Record metadata about user suspensions
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 12s
Checks / Prefligit / prefligit (push) Successful in 31s
Checks / Prefligit / prefligit (pull_request) Successful in 15s
Checks / Rust / Format (push) Successful in 42s
Documentation / Build and Deploy Documentation (pull_request) Successful in 55s
Checks / Rust / Clippy (push) Successful in 3m4s
Checks / Rust / Cargo Test (push) Successful in 5m41s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
ffe34a91db
Jade added 1 commit 2025-06-29 14:17:34 +00:00
feat: Pass sender through admin commands
Some checks failed
Release Docker Image / define-variables (push) Successful in 3s
Checks / Prefligit / prefligit (push) Successful in 29s
Checks / Rust / Format (push) Successful in 57s
Documentation / Build and Deploy Documentation (pull_request) Successful in 53s
Checks / Prefligit / prefligit (pull_request) Successful in 24s
Checks / Rust / Clippy (push) Failing after 3m47s
Checks / Rust / Cargo Test (push) Successful in 5m30s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 12m1s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 11m32s
Release Docker Image / merge (push) Successful in 37s
e01181d7e5
nex added 1 commit 2025-06-29 15:26:14 +00:00
style: Remove redundant, unused functions
All checks were successful
Release Docker Image / define-variables (push) Successful in 4s
Checks / Prefligit / prefligit (push) Successful in 28s
Checks / Rust / Format (push) Successful in 47s
Checks / Prefligit / prefligit (pull_request) Successful in 16s
Documentation / Build and Deploy Documentation (pull_request) Successful in 47s
Checks / Rust / Clippy (push) Successful in 4m26s
Checks / Rust / Cargo Test (push) Successful in 4m48s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 12m56s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 15m11s
Release Docker Image / merge (push) Successful in 19s
e547145748
requested reviews from Jade and removed review requests for Owners 2025-06-29 15:26:33 +00:00
Jade approved these changes 2025-06-29 15:36:50 +00:00
Jade left a comment
Owner

Comments can be fixed when a 'list suspended users' command or something is added

Comments can be fixed when a 'list suspended users' command or something is added
@ -37,2 +38,4 @@
})
}
/// Get the sender as a string, or service user ID if not available
Owner

Oh no this comment is wrong, oh well, never mind

Oh no this comment is wrong, oh well, never mind
@ -227,0 +238,4 @@
if self.services.users.is_admin(&user_id).await {
return Err!("Admin users cannot be suspended.");
}
// TODO: Record the actual user that sent the suspension where possible
Owner

And this one

And this one
nex merged commit d4862b8ead into main 2025-06-29 15:38:02 +00:00
nex deleted branch nex/user-suspension 2025-06-29 15:38:02 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: continuwuation/continuwuity#876
No description provided.