Skip to content

Add an admin backend for instance settings and author management - #112

Draft
ricardoboss wants to merge 5 commits into
mainfrom
features/admin-backend
Draft

Add an admin backend for instance settings and author management#112
ricardoboss wants to merge 5 commits into
mainfrom
features/admin-backend

Conversation

@ricardoboss

Copy link
Copy Markdown
Owner

Closes #25.

What changed

  • Instance settings stored in the database: a configuration provider layered on the existing Setting table (registered last, so stored values take precedence over appsettings.json and the environment). Consumers pick up changes through IOptionsMonitor without a restart. Only keys declared in the settings registry are readable/writable — currently OpenRegistration and HostedUpstream:BaseUrl — so deployment configuration (connection strings, Jwt:*, AllowedOrigins) stays out of reach of the write path.
  • /admin API endpoints (admin-only policy): list/change settings, list authors with roles, promote/demote authors. The last remaining admin can neither be demoted nor delete their account, since onboarding cannot be repeated. Admins may also discontinue, retract and delete packages they do not own (author.CanManage(package)).
  • SDK: new IAdminService plus an IsAdminAsync extension (fails closed, like IsSelfAsync), with typed exceptions for the new error responses; Kiota client regenerated.
  • Frontend: an /admin page with a settings tab (renders whatever descriptors the API declares, so new settings need no frontend change) and an authors tab, reachable from the nav bar for admins only. The package admin toolbar now also shows for admins on packages they do not own.

Notes for reviewers

  • Contract change: Role and SettingKind now serialize as camelCase strings (JsonStringEnumConverter). Previously they were bare integers in the OpenAPI document, which Kiota could not represent as enums. These are the only enums in the contract and both are consumed only by the frontend, so dart pub clients are unaffected.
  • New error status codes following the existing scheme: 490 unknown-setting, 491 invalid-setting-value.
  • No schema changes — the Setting table from the first-time setup is reused. Stored settings are loaded right after migrations run at startup.
  • The branch was rebased onto main after the forgot-password flow landed; every commit builds and the test suite passes at each step.

🤖 Generated with Claude Code

ricardoboss and others added 5 commits August 4, 2026 21:33
Adds a settings layer on top of the `Setting` table the first-time setup
introduced: a configuration provider registered last, so stored values
take precedence over `appsettings.json` and the environment, and
`IOptionsMonitor` consumers pick up a change without a restart and
without changes of their own.

Only keys declared in the settings registry are ever read from or
written to the database. Deployment configuration such as connection
strings, JWT keys and allowed origins therefore stays out of reach of
the write path the admin backend is about to expose.

`OpenRegistration` and `HostedUpstream:BaseUrl` are declared, which is
what makes the note in the README about changing the former at runtime
true for the first time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Lets admins change the instance settings and promote or demote authors
through `/admin`. Changing settings goes through the same service the
settings layer already exposes, so the registry and the value checks are
shared rather than duplicated.

Admins may now also discontinue, retract and delete packages they do not
own. The four owner checks became one predicate, which is the only place
that has to know admins are exempt.

The last remaining admin can no longer be demoted or delete their
account, for the same reason the first-time setup cannot be repeated: an
instance without admins could never be administered again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds `/admin`, reachable from the navigation bar for admins, with a tab
for the instance settings and one listing the authors with their roles.
The settings tab renders whatever the API declares, so a new setting
shows up without frontend changes.

The package admin toolbar is now shown to admins on packages they do not
own, matching what the API accepts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The note about changing `OpenRegistration` at runtime only ever worked
by editing the mounted configuration file, and is now accurate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The setting descriptions rendered twice - as placeholder and as help -
and the help landed beside the input instead of under it, because
sibling children of a horizontal field-body become columns in Bulma.
One inner field per row keeps the input full-width with its description
below, once.

The save button now starts at the input column like the other forms,
and the authors table centers its cells vertically instead of letting
the text hug the top edge of rows the buttons made taller.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Admin dashboard

1 participant