3 Commits

Author SHA1 Message Date
bluefateludi
4277138581 perf(auth): format only the requested account for profile lookups (#3033) 2026-11-30 11:12:32 +08:00
Bingxi Zhao (Frank)
fc39543bc0 feat: integrate frontend backend and canonical routes 2026-09-01 22:24:29 +08:00
Souptik Chakraborty
a5879735b7 fix: Keep env-bootstrapped admin usable and unpromoted (#851)
The identity store had two bugs that combined into a lockout for
deployments whose admin comes from auth.json rather than /register.

load_users() returned the bootstrap admin only when the store was empty,
so writing the first real account dropped it and the operator's login
started returning 401. save_user() then decided first-admin promotion
from load_users() called with no env arguments, an env-blind view, so
with an empty store the first account an admin created from /admin/users
was silently promoted to admin even though that endpoint documents
role="user". Together: create one student account, the student is the
only admin, the operator is locked out.

load_users() now merges the bootstrap admin whenever it is configured; a
stored record with the same username still wins, so the account can be
adopted into the store. The merge stays in memory because no write path
passes the env arguments, so a rotation of auth.json is never shadowed by
a stale persisted hash. save_user() counts a configured bootstrap admin
as an existing account, except when saving that same username, which is
an adoption and keeps the admin role.

The genuinely-empty deployment is unchanged: with no bootstrap
credentials the first /register user is still promoted. A username
configured with an empty hash cannot authenticate and so does not count,
which matters because that is the shipped default.

Fixes #849
2026-08-16 19:07:52 +08:00