feat(tenancy): resources of a tenant, their sealed secrets and the tenant selector #42

Merged
crapougnax merged 1 commit from feat/41-tenant-resources-api into develop 2026-11-17 20:39:05 +00:00
Member

Closes #41. Part of #38 (steps 2 and 3).

What changes

  • Secrets. Migration 0003_tenant_secrets creates the table of the TenantSecret model of @quatrain/tenancy, with row-level security: a statement only sees the secrets of the tenant of the request. Values are sealed (AES-256-GCM, reversible HashProperty) with TENANT_SECRETS_KEY. Without the key the instance keeps no secret and says so.
  • Routes of a tenant, under /t/<tenant>/api/tenant/…: resources (read, change), secrets/<name> (set, delete) for its administrators; overview for any member. A secret value is never returned nor logged.
  • Language model of the instance. PUT /api/admin/tenants/<slug>/instance-model and a switch on the Tenants page, for the administrators of the instance. A tenant cannot grant it to itself.
  • Pages. /t/<tenant>/ is the home of a tenant, /t/<tenant>/resources the page of its administrators. The side menu lists the pages of the tenant when inside one.
  • Tenant selector at the top of the side menu and in the workbench. An account with no role on the instance is sent to its first tenant after signing in.
  • @quatrain/core, backend, tenancy and types move to the betas that carry the reversible HashProperty and the tenant secrets.

The curation routes do not read these resources yet: that is the next step of #38.

Verified

  • yarn test: 152 tests pass. One run out of five showed a single failure that did not come back; I could not identify the test.
  • yarn build passes.
  • On a local PostgreSQL with separate owner and application roles: migration, settings and secrets through the routes, refusals (private address, self-granted instance model, unknown secret, curator, non-member, outside a tenant), the stored value is sealed, the application role sees no secret outside the scope of the tenant, the logs hold no secret value. Pages and selector checked in a browser.

To do when deploying

  • Add TENANT_SECRETS_KEY (openssl rand -base64 32) to the secrets of the deployment.
  • Run yarn admin migrate.

🤖 Generated with Claude Code

Closes #41. Part of #38 (steps 2 and 3). ## What changes - **Secrets.** Migration `0003_tenant_secrets` creates the table of the `TenantSecret` model of `@quatrain/tenancy`, with row-level security: a statement only sees the secrets of the tenant of the request. Values are sealed (AES-256-GCM, reversible `HashProperty`) with `TENANT_SECRETS_KEY`. Without the key the instance keeps no secret and says so. - **Routes of a tenant**, under `/t/<tenant>/api/tenant/…`: `resources` (read, change), `secrets/<name>` (set, delete) for its administrators; `overview` for any member. A secret value is never returned nor logged. - **Language model of the instance.** `PUT /api/admin/tenants/<slug>/instance-model` and a switch on the Tenants page, for the administrators of the instance. A tenant cannot grant it to itself. - **Pages.** `/t/<tenant>/` is the home of a tenant, `/t/<tenant>/resources` the page of its administrators. The side menu lists the pages of the tenant when inside one. - **Tenant selector** at the top of the side menu and in the workbench. An account with no role on the instance is sent to its first tenant after signing in. - `@quatrain/core`, `backend`, `tenancy` and `types` move to the betas that carry the reversible `HashProperty` and the tenant secrets. The curation routes do not read these resources yet: that is the next step of #38. ## Verified - `yarn test`: 152 tests pass. One run out of five showed a single failure that did not come back; I could not identify the test. - `yarn build` passes. - On a local PostgreSQL with separate owner and application roles: migration, settings and secrets through the routes, refusals (private address, self-granted instance model, unknown secret, curator, non-member, outside a tenant), the stored value is sealed, the application role sees no secret outside the scope of the tenant, the logs hold no secret value. Pages and selector checked in a browser. ## To do when deploying - Add `TENANT_SECRETS_KEY` (`openssl rand -base64 32`) to the secrets of the deployment. - Run `yarn admin migrate`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(tenancy): resources of a tenant, their sealed secrets and the tenant selector (#41)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 3m32s
2ec997bd14
A tenant brings its repository, its storage and its language model. Its
administrators declare them on a Resources page, under the URL of the tenant,
and give their credentials, which are sealed with the key of the instance
(TENANT_SECRETS_KEY) and kept in a table protected by row-level security. A
secret is written or deleted, never read back.

Only an administrator of the instance lets a tenant use the language model of
the instance.

A tenant has a home for its members, and an account that may enter tenants
goes from one to the other with a selector. An account with no role on the
instance is sent to its tenant after signing in.

Closes #41

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
crapougnax merged commit 902d01c8fc into develop 2026-11-17 20:39:05 +00:00
crapougnax deleted branch feat/41-tenant-resources-api 2026-11-17 20:39:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
modaka/studio!42
No description provided.