Console: route approved admin sign-in to a role-aware admin panel#52
Merged
Conversation
login/verify, elevate, and whoami (both paths) now include the per-request
resolved role ('superadmin' | 'admin') alongside identity + method, so the
console can route straight to the right panel after approval without a second
round-trip. Role is still NEVER persisted in the session record — it is
re-derived per request (resolveRoledAdmin), so revocation stays effective on
the next request; it rides the response for rendering only.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U8EGtxYhdvUcvhCZLBrXFc
Previously /console/ ended at a 'Signed in' confirmation card with nowhere to
go. Now, once the server approves a login, the console routes on the returned
role:
- superadmin → the admin-management panel: lists the effective admin set
(file-governed principals shown read-only + runtime roster) and adds/removes
RUNTIME admins via the live /api/admin/admins* API — each mutation carries
the session CSRF token and is audit-logged server-side. npub/hex/DID input;
friendly mapping of 400/403/404/409/429/503; auto-refresh after each change;
a 401 anywhere drops back to sign-in.
- admin → a signed-in home (no management tools for this role yet).
Panel state is reset on logout so a next admin never sees the prior roster
view. Stays a static /console/ asset (all calls same-origin), Svelte-only, no
new deps; file principals remain immutable here (PR-governed).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U8EGtxYhdvUcvhCZLBrXFc
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
wecanjustbuildthings | 837769e | Jul 05 2026, 10:53 PM |
MartinMontero
marked this pull request as ready for review
July 5, 2026 23:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes the post-login dead end:
/console/used to end at a "Signed in" confirmation card with nowhere to go, because no admin-panel screen had been built (the P2B slice shipped the roster-management API but explicitly no UI). This wires approval → a real, working panel.Two logical changes, one commit each:
Server (
1083c62) — the admin auth responses (login/verify,elevate,whoamiboth paths) now include the per-request resolvedrole(superadmin|admin) alongsideidentity+method, so the console can route immediately without a second round-trip. Role is still never persisted in the session record — it's re-derived per request (resolveRoledAdmin), so revocation stays effective on the next request; it rides the response purely for rendering.Console UI (
837769e) — once approved,AdminConsole.svelteroutes on the returned role:/api/admin/admins*endpoints. Each mutation carries the session CSRF token (x-admin-csrf) and is audit-logged server-side. Acceptsnpub/hex/DID; maps 400/403/404/409/429/503 to plain messages; auto-refreshes after each change; a 401 anywhere drops cleanly back to sign-in. Panel state is reset on logout so a next admin never sees the prior roster view.File-governed principals stay immutable here — they're changed only through repository PRs, exactly as the two-tier model requires. The API already enforces this (add → 409, remove → 403); the UI simply presents them read-only.
Constraints held
/console/asset (all calls same-origin under the existing CSP; thewss:bunker allowance is untouched); Svelte, never React; no runtime inference (Path A); dependency delta zero (nostr-tools/nip46was already imported). No workflow changes;operational_advisoryuntouched.astro check0 errors; a Chromium render smoke of/console/confirms the login cards mount and the management panel does not leak in the signed-out state (role gating); the server API paths are covered by the worker test suite.Type of change
Required checks
npm run checkpasses (0 errors)npm run enforcepassesnpm testpasses (316/316 — added a role-in-response assertion + strengthened existing ones)npm run buildsucceeds (npm run verify:allexit 0)For catalog entries
Not applicable.
For recipes
Not applicable.
Note
The P2B roster migration is already applied on remote
wcjbt-auth(both tables + index confirmed), so the management panel is backed by live storage the moment this deploys. This PR adds no migration.🤖 Generated with Claude Code
https://claude.ai/code/session_01U8EGtxYhdvUcvhCZLBrXFc
Generated by Claude Code