feat(support): BreakPilot support can open any tenant, attributed and audited #425

Merged
sharang merged 1 commits from feat/support-access into main 2026-09-29 07:37:13 +00:00
Owner

Why

The platform admin needs to see customers' findings, fix mistakes and classify triage results in their tenants. Access should be always on for staff roles, with no invite; the AVV covers support access. It is planned for v0.4.1.

How it works

  • Who:
    • Keycloak realm roles BREAKPILOT_ADMIN or SUPPORT_ENGINEER, which already exist and are granted through the company sign-in.
    • The portal already checks them; Prüfwerk now does too.
  • Choosing a tenant:
    • The dashboard sends X-Pruefwerk-Tenant: <registry id> with every request.
    • The agent honours it only for a support role and only in UUID form. For customer tokens it is ignored (tested).
  • Confirmation:
    • require_entitlement looks the tenant up in the registry (GET /v1/tenants/{id}), and the registry's slug and status replace the read-only placeholder.
    • Unknown tenant → 404; registry down → 503; no registry at all → no support access.
    • The status ladder still applies: archived → 410, halted → 402. Plan limits don't apply to support.
  • Audit:
    • Every non-GET support request, including refused ones, goes to POST /v1/audit as action pruefwerk.support_access, with metadata {method, path, status} and no body or query.
    • Opening a tenant is POST /api/v1/support/session, so it is logged too.
  • Attribution:
    • StatusChange gains by_name and support, so the history shows "BreakPilot-Support (Name)". Customer users now show by name instead of a UUID.
    • Manual findings record reported_by the same way.
  • Usage: ScanTrigger::Support for scans support starts; no scan.completed usage event.
  • Dashboard:
    • Support without a tenant sees a searchable picker (GET /api/v1/support/tenants, from the registry list) instead of the app. Tenant routes return 428 tenant_not_selected, never 401, so there is no login loop.
    • While a tenant is open, a banner shows "Support-Zugriff: {Name}" with "Mandant wechseln".

Platform

Production needs pruefwerk-svc-prod to have tenants.read and audit.write in the registry AUTH_RULES; stage already has them. Without them, support access returns 503 in production.

Tests

  • core:
    • a customer header is ignored;
    • support opens the named tenant read-only;
    • both roles work;
    • no header → no tenant;
    • malformed header refused;
    • TenantCtx → tenant_not_selected;
    • StaffCtx is support-only.
  • agent:
    • the registry confirms slug and status;
    • an unknown status stays read-only;
    • the audit entry has no content;
    • the support ladder: archived 410, halted 402, placeholder read-only, active writes;
    • support history attribution;
    • picker order.
  • dashboard: support role read from the token; picker search.
  • Full suites and clippy with the CI flags on every crate; fmt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

## Why The platform admin needs to see customers' findings, fix mistakes and classify triage results in their tenants. Access should be always on for staff roles, with no invite; the AVV covers support access. It is planned for v0.4.1. ## How it works - **Who:** - Keycloak realm roles `BREAKPILOT_ADMIN` or `SUPPORT_ENGINEER`, which already exist and are granted through the company sign-in. - The portal already checks them; Prüfwerk now does too. - **Choosing a tenant:** - The dashboard sends `X-Pruefwerk-Tenant: <registry id>` with every request. - The agent honours it only for a support role and only in UUID form. For customer tokens it is ignored (tested). - **Confirmation:** - `require_entitlement` looks the tenant up in the registry (`GET /v1/tenants/{id}`), and the registry's slug and status replace the read-only placeholder. - Unknown tenant → 404; registry down → 503; no registry at all → no support access. - The status ladder still applies: archived → 410, halted → 402. Plan limits don't apply to support. - **Audit:** - Every non-GET support request, including refused ones, goes to `POST /v1/audit` as action `pruefwerk.support_access`, with metadata `{method, path, status}` and no body or query. - Opening a tenant is `POST /api/v1/support/session`, so it is logged too. - **Attribution:** - `StatusChange` gains `by_name` and `support`, so the history shows "BreakPilot-Support (Name)". Customer users now show by name instead of a UUID. - Manual findings record `reported_by` the same way. - **Usage:** `ScanTrigger::Support` for scans support starts; no `scan.completed` usage event. - **Dashboard:** - Support without a tenant sees a searchable picker (`GET /api/v1/support/tenants`, from the registry list) instead of the app. Tenant routes return `428 tenant_not_selected`, never 401, so there is no login loop. - While a tenant is open, a banner shows "Support-Zugriff: {Name}" with "Mandant wechseln". ## Platform Production needs `pruefwerk-svc-prod` to have `tenants.read` and `audit.write` in the registry `AUTH_RULES`; stage already has them. Without them, support access returns 503 in production. ## Tests - **core:** - a customer header is ignored; - support opens the named tenant read-only; - both roles work; - no header → no tenant; - malformed header refused; - `TenantCtx` → `tenant_not_selected`; - `StaffCtx` is support-only. - **agent:** - the registry confirms slug and status; - an unknown status stays read-only; - the audit entry has no content; - the support ladder: archived 410, halted 402, placeholder read-only, active writes; - support history attribution; - picker order. - **dashboard:** support role read from the token; picker search. - Full suites and clippy with the CI flags on every crate; fmt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-09-29 07:29:23 +00:00
feat(support): BreakPilot support can open any tenant, attributed and audited
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m6s
4d3035a8c7
Staff with the realm role BREAKPILOT_ADMIN or SUPPORT_ENGINEER (company
sign-in) can open any customer tenant in the dashboard without being
invited, as the AVV allows.

- Agent: a support token names the tenant in X-Pruefwerk-Tenant (UUID
  only; ignored for every other token, so customers cannot switch). The
  context stays read-only until the registry confirms the tenant, which
  also sets its slug and ladder status: archived and halted tenants stay
  closed. Without a registry there is no support access.
- Support without a chosen tenant gets 428 tenant_not_selected on
  tenant routes, not a 401, so the dashboard never loops to the login.
- Every support change, refused ones included, goes to the registry's
  audit log (method, path, status; never the body). Opening a tenant is
  logged through POST /api/v1/support/session.
- Status history records a display name and a support flag: the customer
  reads "BreakPilot-Support (name)"; everyone else's changes now show a
  name instead of a user id. Manual findings name their reporter.
- Scans support starts run as ScanTrigger::Support and are not counted
  as the customer's usage.
- Dashboard: support lands on a searchable tenant picker; a banner shows
  while a tenant is open, with "Mandant wechseln".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 96d97ae6eb into main 2026-09-29 07:37:13 +00:00
Sign in to join this conversation.