feat(agent): registry entitlements, platform endpoints, JWT aud/iss #246

Merged
sharang merged 2 commits from feat/m-mig-6-registry-entitlements into main 2026-09-12 07:39:01 +00:00
Owner

Prüfwerk slice of M-MIG-6 (products on staging) — implements PRODUCT_INTEGRATION_SPEC 2.0 §4.1 / §4.4 / §9.2 against the tenant-registry (platform/tenant-registry#23).

What changes

  • Tenant ladder (compliance-core::tenant): demo|trial|active|warning|restricted|frozen|halted|archived. restricted/frozen block writes (402), halted blocks everything (402), archived → 410.
  • JWT hardening: issuer pinned to {KEYCLOAK_URL}/realms/{REALM}, audience validated (KEYCLOAK_AUDIENCE, default pruefwerk, empty string disables for dev). New validate_service_token() for client_credentials tokens (azp).
  • Registry client (compliance-agent::registry): client_credentials token cache, POST /v1/internal/entitlements/check cached ≤60 s and fail-closed (503 when the registry is unreachable and nothing is cached), GET /v1/tenants with cursor, POST /v1/internal/api-keys/verify, POST /v1/usage/events.
  • Entitlement gate: require_entitlement runs between the JWT and status middlewares; the registry's status/read-only answer overrides the tenant_status claim (never widens). No registry configured → no-op (dev).
  • Platform endpoints /api/v1/platform/*: version, usage?tenant_id&from&to, tenants/{id}/provision|suspend|reactivate|terminate, GET tenants/{id}/export, DELETE tenants/{id}/data (needs confirm), tenants/demo/reset. Gated by a service token whose azp ∈ PLATFORM_ALLOWED_CLIENTS (default tenant-registry-svc-{stage,prod}, portal-svc-{stage,prod}).
  • CORS: allowlist from CORS_ALLOWED_ORIGINS; permissive only when unset (logged).
  • Werkbank runners: bearer bp_… registry API keys with scope werkbank:runner accepted next to the static WERKBANK_RUNNER_TOKEN; router mounted when either is available.
  • Scheduler: tenant list from the registry client, filtered to active|trial|demo|warning.
  • .env.example documents PRODUCT_KEY, TENANT_REGISTRY_URL/CLIENT_ID/CLIENT_SECRET, KEYCLOAK_AUDIENCE, CORS_ALLOWED_ORIGINS, PLATFORM_ALLOWED_CLIENTS.

Not in this PR

  • Usage event emission on scan completion / target add (M-MIG-7, with the registry outbox).
  • Export as streamed archive (JSON document for now).
  • Crate renames compliance-* → pruefwerk-* (deferred per plan).

Verification

  • cargo clippy -p compliance-agent -- -D warnings, -p compliance-mcp: clean
  • cargo test -p compliance-core -p compliance-agent --lib: 312 + 52 pass
  • cargo test -p compliance-agent --test tenant_status_middleware (new ladder cases) and --test werkbank_api: pass
  • cargo check -p compliance-dashboard --features server --no-default-features: ok
  • Pre-existing, untouched: compliance-core/tests/models.rs does not compile on main either (TrackedRepository).

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Prüfwerk slice of **M-MIG-6** (products on staging) — implements PRODUCT_INTEGRATION_SPEC 2.0 §4.1 / §4.4 / §9.2 against the tenant-registry (platform/tenant-registry#23). ## What changes - **Tenant ladder** (`compliance-core::tenant`): `demo|trial|active|warning|restricted|frozen|halted|archived`. `restricted`/`frozen` block writes (402), `halted` blocks everything (402), `archived` → 410. - **JWT hardening**: issuer pinned to `{KEYCLOAK_URL}/realms/{REALM}`, audience validated (`KEYCLOAK_AUDIENCE`, default `pruefwerk`, empty string disables for dev). New `validate_service_token()` for client_credentials tokens (`azp`). - **Registry client** (`compliance-agent::registry`): client_credentials token cache, `POST /v1/internal/entitlements/check` cached ≤60 s and **fail-closed** (503 when the registry is unreachable and nothing is cached), `GET /v1/tenants` with cursor, `POST /v1/internal/api-keys/verify`, `POST /v1/usage/events`. - **Entitlement gate**: `require_entitlement` runs between the JWT and status middlewares; the registry's status/read-only answer overrides the `tenant_status` claim (never widens). No registry configured → no-op (dev). - **Platform endpoints** `/api/v1/platform/*`: `version`, `usage?tenant_id&from&to`, `tenants/{id}/provision|suspend|reactivate|terminate`, `GET tenants/{id}/export`, `DELETE tenants/{id}/data` (needs `confirm`), `tenants/demo/reset`. Gated by a service token whose `azp` ∈ `PLATFORM_ALLOWED_CLIENTS` (default `tenant-registry-svc-{stage,prod}`, `portal-svc-{stage,prod}`). - **CORS**: allowlist from `CORS_ALLOWED_ORIGINS`; permissive only when unset (logged). - **Werkbank runners**: bearer `bp_…` registry API keys with scope `werkbank:runner` accepted next to the static `WERKBANK_RUNNER_TOKEN`; router mounted when either is available. - **Scheduler**: tenant list from the registry client, filtered to `active|trial|demo|warning`. - `.env.example` documents `PRODUCT_KEY`, `TENANT_REGISTRY_URL/CLIENT_ID/CLIENT_SECRET`, `KEYCLOAK_AUDIENCE`, `CORS_ALLOWED_ORIGINS`, `PLATFORM_ALLOWED_CLIENTS`. ## Not in this PR - Usage event *emission* on scan completion / target add (M-MIG-7, with the registry outbox). - Export as streamed archive (JSON document for now). - Crate renames `compliance-*` → `pruefwerk-*` (deferred per plan). ## Verification - `cargo clippy -p compliance-agent -- -D warnings`, `-p compliance-mcp`: clean - `cargo test -p compliance-core -p compliance-agent --lib`: 312 + 52 pass - `cargo test -p compliance-agent --test tenant_status_middleware` (new ladder cases) and `--test werkbank_api`: pass - `cargo check -p compliance-dashboard --features server --no-default-features`: ok - Pre-existing, untouched: `compliance-core/tests/models.rs` does not compile on `main` either (`TrackedRepository`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-11 15:50:45 +00:00
feat(agent): registry entitlements, platform endpoints, JWT aud/iss
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 5m52s
e448a33778
Prüfwerk M-MIG-6 slice (PRODUCT_INTEGRATION_SPEC 2.0):

- core: tenant status ladder demo|trial|active|warning|restricted|frozen|
  halted|archived; blocks_writes()/is_halted(); status gate returns 402
  for halted on every route, 410 for archived
- core auth: JwksState::new(jwks_url, issuer, audience) — issuer pinned,
  audience validated (KEYCLOAK_AUDIENCE, default pruefwerk);
  validate_service_token() for client_credentials tokens (azp)
- agent: RegistryClient (client_credentials token cache, entitlement
  check cached 60 s fail-closed, tenant list w/ cursor, api-key verify,
  usage push); require_entitlement middleware between JWT and status
  gate; registry answer overrides the tenant_status claim
- agent: /api/v1/platform/{version,usage,tenants/{id}/provision|suspend|
  reactivate|terminate|export,tenants/{id}/data DELETE,tenants/demo/reset}
  behind service-token gate + PLATFORM_ALLOWED_CLIENTS allowlist
- agent: CORS allowlist from CORS_ALLOWED_ORIGINS (permissive only when
  unset, logged)
- agent: werkbank runner auth accepts registry API keys (bp_…, scope
  werkbank:runner) next to the static token; router mounted when either
  is available
- agent: scheduler lists tenants via the registry client and skips
  restricted/frozen/halted/archived
- smoke: use JwksState::new; .env.example documents the new variables

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-11 16:10:33 +00:00
docs: serve the site under /docs/ (VitePress base + nginx)
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 5m56s
9550effa34
On the platform cluster the docs are an orca route (/docs/*) on the
dashboard host, prefix not stripped. Build with base /docs/, copy the
dist to html/docs, redirect / → /docs/.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 5822b51cec into main 2026-09-12 07:39:01 +00:00
sharang deleted branch feat/m-mig-6-registry-entitlements 2026-09-12 07:39:02 +00:00
Sign in to join this conversation.