Skip to content

Console: route approved admin sign-in to a role-aware admin panel#52

Merged
MartinMontero merged 2 commits into
mainfrom
claude/admin-role-tiers-oux5ar
Jul 5, 2026
Merged

Console: route approved admin sign-in to a role-aware admin panel#52
MartinMontero merged 2 commits into
mainfrom
claude/admin-role-tiers-oux5ar

Conversation

@MartinMontero

Copy link
Copy Markdown
Owner

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:

  1. Server (1083c62) — the admin auth responses (login/verify, elevate, whoami both paths) now include the per-request resolved role (superadmin | admin) alongside identity + 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.

  2. Console UI (837769e) — once approved, AdminConsole.svelte routes on the returned role:

    • superadmin → the admin-management panel: lists the effective admin set (file-governed principals shown read-only + the runtime roster) and adds/removes runtime admins via the live /api/admin/admins* endpoints. Each mutation carries the session CSRF token (x-admin-csrf) and is audit-logged server-side. Accepts npub/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.
    • admin → a signed-in home (no management tools for this role yet).

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

  • Stays a static /console/ asset (all calls same-origin under the existing CSP; the wss: bunker allowance is untouched); Svelte, never React; no runtime inference (Path A); dependency delta zero (nostr-tools/nip46 was already imported). No workflow changes; operational_advisory untouched.
  • Verified: astro check 0 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

  • New catalog entry
  • Fix/update to an existing entry
  • New or updated recipe
  • Build flow / docs
  • Enforcement engine / tooling
  • Other — admin console UI

Required checks

  • npm run check passes (0 errors)
  • npm run enforce passes
  • npm test passes (316/316 — added a role-in-response assertion + strengthened existing ones)
  • npm run build succeeds (npm run verify:all exit 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

claude added 2 commits July 5, 2026 22:41
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
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
wecanjustbuildthings 837769e Jul 05 2026, 10:53 PM

@MartinMontero
MartinMontero marked this pull request as ready for review July 5, 2026 23:01
@MartinMontero
MartinMontero merged commit 3a5fa9c into main Jul 5, 2026
14 checks passed
@MartinMontero
MartinMontero deleted the claude/admin-role-tiers-oux5ar branch July 5, 2026 23:01
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