Admin console backend spine (#33): /v1/me, staff management, custom-key minting #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/admin-backend-33"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First, self-contained slice of the #33 staff-console backend — the real auth gate plus the two headline staff capabilities (add admins, mint custom keys), all session-gated.
Endpoints (all gated on a staff account session)
GET /v1/me→{email, admin}— the real gate admin.html checks (any signed-in account; admin.html's@swisscairn.chcheck is only a UI hint).GET /v1/admin/admins→ staff roster.POST /v1/admin/admins→ add / re-role / remove staff. Owner-only; enforces@swisscairn.ch, last-owner protection, and no self-change. Keyed offrole(a present role upserts, empty/null removes) to match admin.html, which sendsadmin:falseeven for analyst adds.POST /v1/admin/mint→ mint a signed custom license (unlimited/perpetual/custom-expiry/air-gapped/free) + audit record. Owner and admin may mint; analyst may not.GET /v1/admin/audit→ append-only audit trail (newest first).Design
admin.goowns two SQLite tables (admins,audit) directly via the store's*sql.DB. It touches neither the storesave()/load()rewrite path nor theaccountstruct — the change is purely additive.ADMIN_ACCOUNTS(comma-separated, defaultno-reply@swisscairn.ch) as roleowner. Roles: owner (manage staff + mint), admin (mint), analyst (read-only).main()to register the routes (via a self-removing one-shot workflow).Deliberately deferred (Phase 2)
The analytics that need per-request event capture —
/v1/admin/{overview,accounts,heatmap/geo,funnel}and per-account timeline — plus offline GeoIP. Those endpoints are not registered here, so admin.html keeps its client-side fixtures for them rather than showing a fabricated-empty dashboard. Funnel will be fed from the existing Paddle webhook; geo from login-IP → offline GeoIP.Tests
admin_test.go:/v1/megate (staff vs non-staff), staff management (add admin+analyst, domain rejection, self-change block, non-owner cannot manage, removal), and minting (full custom key → 201 + audit, missing-reason 400, perpetual+expiry 400, analyst-cannot-mint 403).