Connections between tenants: a two-way handshake by code (for Prüfwerk supplier SBOM releases) #138

Closed
opened 2026-11-18 12:56:59 +00:00 by sharang · 1 comment
Owner

Prüfwerk needs product-neutral connections between tenants: a two-way handshake that one tenant starts and the other accepts. Phase 4 of Prüfwerk's supplier SBOM epic (platform/pruefwerk#1028) builds on it: a supplier tenant releases the SBOM of a product to a connected customer tenant. The plan, with the user's decisions of 2026-11-18, is on platform/pruefwerk#1028.

Prüfwerk keeps the releases and what is received in its own tenant databases. The registry only answers who is connected to whom.

Rules (GDPR)

  • No directory: no tenant can find, list or search other tenants. Nothing in this API changes that.
  • Nothing before acceptance: before B accepts, neither side learns anything about the other. After that, each sees only the other's display name, never its id, slug or members.
  • Codes:
    • high-entropy (at least 128 bits), single-use, and stored as a hash only;
    • valid for 14 days (proposed);
    • redeeming is rate-limited per tenant and per caller;
    • an unknown, used or expired code all get the same answer.
  • Ending: either side can end a connection at any time. Terminating or erasing a tenant ends all its connections.
  • Audit: creating a code, accepting, and ending are recorded in the audit log of both tenants.
  • Who may do it: IT_ADMIN (proposed).

API (sketch)

Through the portal, on behalf of a signed-in IT_ADMIN of tenant {id}:

Call What it does
POST /v1/tenants/{id}/connection-invites Creates a code. Answers 201 {code, expires_at}; the code is shown once.
DELETE /v1/tenants/{id}/connection-invites/{invite} Withdraws an unused code.
POST /v1/tenants/{id}/connections {code} Accepts a code. The connection is active at once. Answers 201 {id, peer_name, created_at}, or 404 for any code that is not valid.
GET /v1/tenants/{id}/connections The tenant's connections: id, peer_name, state (active, ended), created_at, ended_at, ended_by_us.
POST /v1/tenants/{id}/connections/{connection}/end Ends a connection.

For products, with a service token:

Call What it does
GET /v1/internal/tenants/{id}/connections?state=active The tenant's active connections: id, peer_tenant_id, peer_name. Prüfwerk uses the peer id only internally, to deliver to that tenant's database. It never shows it.
GET /v1/internal/connections/{connection} {active, tenant_ids: [a, b]}. Prüfwerk checks this before every delivery.

Connections are product-neutral: one connection can carry Prüfwerk releases now and other products' data later. Each product asks its own consent for what it sends over a connection.

Done when

  • Two tenants connect by code. A code works once and only until it expires. All invalid codes get the same answer.
  • Either side can end a connection. Terminating or erasing a tenant ends all its connections.
  • A product can list a tenant's active connections and check a single connection.
  • No endpoint lists, searches or reveals a tenant that is not connected.
  • Both tenants' audit logs record each step.
Prüfwerk needs product-neutral **connections between tenants**: a two-way handshake that one tenant starts and the other accepts. Phase 4 of Prüfwerk's supplier SBOM epic (platform/pruefwerk#1028) builds on it: a supplier tenant releases the SBOM of a product to a connected customer tenant. The plan, with the user's decisions of 2026-11-18, is on platform/pruefwerk#1028. Prüfwerk keeps the releases and what is received in its own tenant databases. The registry only answers who is connected to whom. ## Rules (GDPR) - **No directory:** no tenant can find, list or search other tenants. Nothing in this API changes that. - **Nothing before acceptance:** before B accepts, neither side learns anything about the other. After that, each sees only the other's **display name**, never its id, slug or members. - **Codes:** - high-entropy (at least 128 bits), single-use, and stored as a hash only; - valid for 14 days (proposed); - redeeming is rate-limited per tenant and per caller; - an unknown, used or expired code all get the same answer. - **Ending:** either side can end a connection at any time. Terminating or erasing a tenant ends all its connections. - **Audit:** creating a code, accepting, and ending are recorded in the audit log of both tenants. - **Who may do it:** `IT_ADMIN` (proposed). ## API (sketch) **Through the portal**, on behalf of a signed-in `IT_ADMIN` of tenant `{id}`: | Call | What it does | |---|---| | `POST /v1/tenants/{id}/connection-invites` | Creates a code. Answers `201 {code, expires_at}`; the code is shown once. | | `DELETE /v1/tenants/{id}/connection-invites/{invite}` | Withdraws an unused code. | | `POST /v1/tenants/{id}/connections` `{code}` | Accepts a code. The connection is active at once. Answers `201 {id, peer_name, created_at}`, or `404` for any code that is not valid. | | `GET /v1/tenants/{id}/connections` | The tenant's connections: `id`, `peer_name`, `state` (`active`, `ended`), `created_at`, `ended_at`, `ended_by_us`. | | `POST /v1/tenants/{id}/connections/{connection}/end` | Ends a connection. | **For products**, with a service token: | Call | What it does | |---|---| | `GET /v1/internal/tenants/{id}/connections?state=active` | The tenant's active connections: `id`, `peer_tenant_id`, `peer_name`. Prüfwerk uses the peer id only internally, to deliver to that tenant's database. It never shows it. | | `GET /v1/internal/connections/{connection}` | `{active, tenant_ids: [a, b]}`. Prüfwerk checks this before every delivery. | Connections are product-neutral: one connection can carry Prüfwerk releases now and other products' data later. Each product asks its own consent for what it sends over a connection. ## Done when - [ ] Two tenants connect by code. A code works once and only until it expires. All invalid codes get the same answer. - [ ] Either side can end a connection. Terminating or erasing a tenant ends all its connections. - [ ] A product can list a tenant's active connections and check a single connection. - [ ] No endpoint lists, searches or reveals a tenant that is not connected. - [ ] Both tenants' audit logs record each step.
Author
Owner

Note from the Prüfwerk side, found on stage (agent 0.4.16):

The two internal routes need their own authz group. routeGroup in internal/server/authz.go has no case for /v1/internal/tenants/ or /v1/internal/connections/, so both fall into other. pruefwerk-svc-stage isn't granted other, so the registry answers 403 before the mux is reached.

Today, without the routes, Prüfwerk's GET /v1/internal/tenants/{id}/connections?state=active gets a 403 instead of a 404. The supplier release screen then warns that connections can't be read.

What #138 needs for Prüfwerk:

  • a case in routeGroup, e.g. connections (or connections.read), for /v1/internal/tenants/{id}/connections and /v1/internal/connections/{connection}, kept in sync with NewRouter
  • that group added to the Prüfwerk client in AUTHZ_RULES on stage and prod (pruefwerk-svc-stage:...,connections)

The portal routes under /v1/tenants/{id}/connections… already fall into tenants.read / tenants.write, so they need nothing extra.

Prüfwerk keeps treating 403 as an error on purpose: once this ships, a missing grant should show up as a warning, not quietly as "no customers". A 404 (route or tenant unknown) reads as "no connections".

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9

Note from the Prüfwerk side, found on stage (agent 0.4.16): **The two internal routes need their own authz group.** `routeGroup` in `internal/server/authz.go` has no case for `/v1/internal/tenants/` or `/v1/internal/connections/`, so both fall into `other`. `pruefwerk-svc-stage` isn't granted `other`, so the registry answers **403** before the mux is reached. Today, without the routes, Prüfwerk's `GET /v1/internal/tenants/{id}/connections?state=active` gets a 403 instead of a 404. The supplier release screen then warns that connections can't be read. What #138 needs for Prüfwerk: - a case in `routeGroup`, e.g. `connections` (or `connections.read`), for `/v1/internal/tenants/{id}/connections` and `/v1/internal/connections/{connection}`, kept in sync with `NewRouter` - that group added to the Prüfwerk client in `AUTHZ_RULES` on stage and prod (`pruefwerk-svc-stage:...,connections`) The portal routes under `/v1/tenants/{id}/connections…` already fall into `tenants.read` / `tenants.write`, so they need nothing extra. Prüfwerk keeps treating 403 as an error on purpose: once this ships, a missing grant should show up as a warning, not quietly as "no customers". A 404 (route or tenant unknown) reads as "no connections". 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/tenant-registry#138