feat(admin): staff tenant list, detail, trial extension, invite resend #33

Merged
sharang merged 1 commits from feat/staff-admin into main 2026-09-23 19:58:00 +00:00
Owner

F1 of the go-live plan (staff admin area at app.breakpilot.com/admin), registry side.

New route group admin, for the portal's service client only:

Route What
GET /v1/admin/tenants?q=&status=&kind= search slug, name or admin email (LIKE wildcards escaped); each item carries activity: 30-day usage totals per metric and last audit time, in one query per page
GET /v1/admin/tenants/{id} tenant, activity, entitlements, subscriptions, licences, latest 25 audit entries, Keycloak members (best effort, members_error on failure)
POST /v1/admin/tenants/{id}/trial {days} moves the trial end and the trial entitlements; reopens a tenant that an expired trial made read-only, but only if it never had a subscription
POST /v1/admin/tenants/{id}/invites/resend {email} resends the Keycloak execute-actions mail to an existing member
GET /v1/admin/audit audit across tenants

Staff attribution: emitAudit records X-Staff-Subject / X-Staff-Email as actor (type staff) when the calling client holds admin. A product client or a user token cannot claim it.

Store: TenantFilter.Query and TenantActivity in memory and Postgres. Keycloak: ResendInvite. OpenAPI documented.

Deploy: add admin to portal-svc-* in AUTHZ_RULES (orca-platform).

Tests: both stores (Postgres via testcontainers), plus a unit test that only admin clients can claim a staff actor.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

F1 of the go-live plan (staff admin area at `app.breakpilot.com/admin`), registry side. New route group `admin`, for the portal's service client only: | Route | What | |---|---| | `GET /v1/admin/tenants?q=&status=&kind=` | search slug, name or admin email (LIKE wildcards escaped); each item carries `activity`: 30-day usage totals per metric and last audit time, in one query per page | | `GET /v1/admin/tenants/{id}` | tenant, activity, entitlements, subscriptions, licences, latest 25 audit entries, Keycloak members (best effort, `members_error` on failure) | | `POST /v1/admin/tenants/{id}/trial {days}` | moves the trial end and the trial entitlements; reopens a tenant that an expired trial made read-only, but only if it never had a subscription | | `POST /v1/admin/tenants/{id}/invites/resend {email}` | resends the Keycloak execute-actions mail to an existing member | | `GET /v1/admin/audit` | audit across tenants | **Staff attribution:** `emitAudit` records `X-Staff-Subject` / `X-Staff-Email` as actor (type `staff`) when the calling client holds `admin`. A product client or a user token cannot claim it. Store: `TenantFilter.Query` and `TenantActivity` in memory and Postgres. Keycloak: `ResendInvite`. OpenAPI documented. Deploy: add `admin` to `portal-svc-*` in `AUTHZ_RULES` (orca-platform). Tests: both stores (Postgres via testcontainers), plus a unit test that only admin clients can claim a staff actor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-23 17:23:04 +00:00
feat(admin): staff tenant list, detail, trial extension, invite resend
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 22m40s
ci / image (pull_request) Skipped
bab7475a6c
A new route group "admin" (the portal's service client only) serves
the staff admin area: tenant search with 30-day usage and last
activity, one detail call with entitlements, subscriptions, licences,
members and recent audit, trial extension (moves trial entitlements
with it and reopens a trial that expired into read-only), invite
resend, and the audit log across tenants.

Changes made from the admin area are audited under the staff member
the portal names in X-Staff-Subject / X-Staff-Email; the header only
counts from a client that holds the admin group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 54e9f6a720 into main 2026-09-23 19:58:00 +00:00
Sign in to join this conversation.