Skip to content

Work towards removing is_server_owner#1204

Merged
aaronleopold merged 9 commits into
stumpapp:improve-permissioningfrom
Kernald:server-owner
Jun 2, 2026
Merged

Work towards removing is_server_owner#1204
aaronleopold merged 9 commits into
stumpapp:improve-permissioningfrom
Kernald:server-owner

Conversation

@Kernald
Copy link
Copy Markdown
Contributor

@Kernald Kernald commented Jun 1, 2026

Another batch of work towards removing is_server_owner. I'm not using some of the features here (especially book clubs), so would be keen on getting some feedback on whether the permission sets make sense here!

Kernald added 9 commits May 10, 2026 22:00
This consolidates the permission-check logic of this guard to be consistent with `has_permission` and `enforce_permissions`.

Also clean up a few tests.
Except for tests, these were now unused.
Wire the remaining missing permissions equivalent to server owner to
`ManageServer`. Some of these permissions will likely need to be removed
eventually (`AccessKoreaderSync`...), but keeping them now to avoid
breaking changes.
This follows the same existing logic that currently grants
`is_server_owner`, which will eventually be removed.
Both remaining usages now have an easy alternative granted through
`ManageServer`.
This routes the API key validation (which acts on a `LoginUser`) through
`has_permission` for consistency with the rest of permissions handling.
It might be worth surfacing some sort of warning in the UI, e.g. when
trying to delete the last user with `ManageServer` permission, but given
that this permission is something that can be granted to multiple users,
I'm not sure it makes sense to just prevent that in the mutation
anymore.
Decouple book-club moderation from server owner. Two new permissions:
 - `ModerateBookClubs`: moderator-tier across all clubs: edit/delete any
message, lock/pin/create/archive discussions, see clubs the user isn't a
member of
 - `ManageBookClubs`: admin-tier across all clubs: everything
`ModerateBookClubs` grants, plus suggestion administration.

`ManageServer` associates to `ManageBookClubs`, so previously owners
retain the same behaviour.
Copy link
Copy Markdown
Collaborator

@aaronleopold aaronleopold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me!

I'm not using some of the features here (especially book clubs), so would be keen on getting some feedback on whether the permission sets make sense here!

I think what you have is perfectly reasonable 🙂

let is_updating_server_owner = by_user.is_server_owner && by_user.id == for_user_id;
if !is_updating_server_owner {
update_user_age_restriction(&for_user_id, &input.age_restriction, &txn).await?;
update_user_age_restriction(&for_user_id, &input.age_restriction, &txn).await?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's possible for a user to have age restrictions and manage server permissions? I don't personally use age restriction features, and esp not for those I grant admin access lol, so perhaps a non-issue for people who do use it

@aaronleopold aaronleopold merged commit 17e0b8e into stumpapp:improve-permissioning Jun 2, 2026
4 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 76.98413% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rates/graphql/src/mutation/book_club_discussion.rs 0.00% 6 Missing ⚠️
crates/graphql/src/guard.rs 86.11% 5 Missing ⚠️
apps/server/src/routers/api/v2/auth.rs 0.00% 4 Missing ⚠️
apps/server/src/routers/api/v2/oidc.rs 0.00% 4 Missing ⚠️
crates/graphql/src/mutation/user.rs 0.00% 3 Missing ⚠️
crates/models/src/entity/user.rs 25.00% 3 Missing ⚠️
...rates/graphql/src/mutation/book_club_suggestion.rs 0.00% 2 Missing ⚠️
apps/server/src/middleware/auth.rs 0.00% 1 Missing ⚠️
crates/graphql/src/query/book_club_discussion.rs 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
crates/graphql/src/data.rs 46.66% <100.00%> (ø)
crates/graphql/src/query/media.rs 4.51% <ø> (ø)
crates/models/src/entity/book_club.rs 83.70% <100.00%> (ø)
crates/models/src/entity/book_club_member.rs 73.03% <100.00%> (ø)
crates/models/src/shared/enums.rs 0.00% <ø> (ø)
crates/models/src/shared/permission_set.rs 83.03% <100.00%> (ø)
apps/server/src/middleware/auth.rs 53.15% <0.00%> (ø)
crates/graphql/src/query/book_club_discussion.rs 0.00% <0.00%> (ø)
...rates/graphql/src/mutation/book_club_suggestion.rs 0.00% <0.00%> (ø)
crates/graphql/src/mutation/user.rs 13.15% <0.00%> (ø)
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants