feat(documents): tenant documents in object storage #34

Merged
sharang merged 3 commits from feat/documents into main 2026-09-23 20:31:56 +00:00
Owner

F2 of the go-live plan ("Unterlagen"), registry side. Stacked on #33: merge #33 first.

Route Group What
POST /v1/admin/tenants/{id}/documents admin multipart upload (title, description, file) → draft; streamed to S3 with SHA-256; limit DOCUMENTS_MAX_MB (200); allowed pdf/zip/docx/xlsx/pptx/png/jpg/txt/csv/json/xml
GET /v1/admin/tenants/{id}/documents admin all, drafts included
POST /v1/admin/documents/{doc}/publish admin visible to the tenant (idempotent); the F3 mail hook goes here
DELETE /v1/admin/documents/{doc} admin file + row
GET /v1/tenants/{id}/documents tenants.read published only (via the {id}/{sub} route, like members)
GET /v1/tenants/{id}/documents/{doc}/download tenants.read 5-minute presigned URL; audit document.downloaded (user, or X-Portal-User-Email from the portal)
  • Migration 0008_documents; store in memory and Postgres.
  • internal/storage: minio-go against Hetzner (creates the bucket in DOCUMENTS_S3_REGION when missing) plus an in-memory fake.
  • Config: DOCUMENTS_S3_ENDPOINT, _REGION (nbg1), _BUCKET, _ACCESS_KEY, _SECRET_KEY, DOCUMENTS_MAX_MB. Unset → 503 on these routes only.
  • Object keys never leave the registry (json:"-"). File names are sanitised. Content-Disposition carries the UTF-8 name (RFC 5987).

Tests: both stores (upload → draft hidden → publish → download → cross-tenant 404 → delete), type, size and storage failures, the unconfigured case; OpenAPI documented.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

F2 of the go-live plan ("Unterlagen"), registry side. **Stacked on #33**: merge #33 first. | Route | Group | What | |---|---|---| | `POST /v1/admin/tenants/{id}/documents` | admin | multipart upload (title, description, file) → draft; streamed to S3 with SHA-256; limit `DOCUMENTS_MAX_MB` (200); allowed pdf/zip/docx/xlsx/pptx/png/jpg/txt/csv/json/xml | | `GET /v1/admin/tenants/{id}/documents` | admin | all, drafts included | | `POST /v1/admin/documents/{doc}/publish` | admin | visible to the tenant (idempotent); the F3 mail hook goes here | | `DELETE /v1/admin/documents/{doc}` | admin | file + row | | `GET /v1/tenants/{id}/documents` | tenants.read | published only (via the `{id}/{sub}` route, like members) | | `GET /v1/tenants/{id}/documents/{doc}/download` | tenants.read | 5-minute presigned URL; audit `document.downloaded` (user, or `X-Portal-User-Email` from the portal) | - Migration **0008_documents**; store in memory and Postgres. - `internal/storage`: minio-go against Hetzner (creates the bucket in `DOCUMENTS_S3_REGION` when missing) plus an in-memory fake. - Config: `DOCUMENTS_S3_ENDPOINT`, `_REGION` (nbg1), `_BUCKET`, `_ACCESS_KEY`, `_SECRET_KEY`, `DOCUMENTS_MAX_MB`. Unset → 503 on these routes only. - Object keys never leave the registry (`json:"-"`). File names are sanitised. `Content-Disposition` carries the UTF-8 name (RFC 5987). Tests: both stores (upload → draft hidden → publish → download → cross-tenant 404 → delete), type, size and storage failures, the unconfigured case; OpenAPI documented. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 2 commits 2026-09-23 17:35:07 +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
feat(documents): tenant documents in object storage
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m11s
ci / image (pull_request) Skipped
da6eef6d30
Staff upload a file for a tenant as a draft (streamed to an S3 bucket,
hashed on the way, never buffered whole), publish it, or delete it;
the tenant lists its published documents and gets a five-minute
presigned download link. Uploads, publications and downloads are
audited, a download under the person the portal names.

Migration 0008 adds the documents table; internal/storage wraps
minio-go (Hetzner Object Storage, the bucket is created in its
region when missing). Without DOCUMENTS_S3_* the routes answer 503
and the rest of the registry is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-23 19:58:33 +00:00
chore(merge): main into feat/documents after #33
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 23m3s
ci / image (pull_request) Skipped
e99b79f3ff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 8d3cda4bb0 into main 2026-09-23 20:31:56 +00:00
Sign in to join this conversation.