Commit Graph
8 Commits
Author SHA1 Message Date
Sharang ParnerkarandClaude Opus 5.5 6880f3afc2 feat(notify): branded notification mail through an outbox
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m15s
ci / image (pull_request) Skipped
Publishing a document now mails the workspace members who may read
documents, and products can POST /v1/notifications (route group
"notify") to report new findings, which reach IT_ADMIN, OWNER, CXO
and LEGAL. Demo tenants and tenants without an organization get
nothing.

Every mail is a mail_outbox row (migration 0009), one per recipient,
idempotent per key, sent by a worker with backoff and parked with its
error after twelve attempts. Messages are rendered when sent from
embedded German and English templates in the BreakPilot layout, as
multipart text + HTML, through the SMTP relay (SMTP_*).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 19:45:14 +02:00
Sharang ParnerkarandClaude Opus 5.5 da6eef6d30 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
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
2026-09-23 19:35:05 +02:00
Sharang ParnerkarandClaude Opus 5.5 bab7475a6c 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
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
2026-09-23 19:23:00 +02:00
sharangandSharang Parnerkar 99214c088b feat(members): tenant organization members, invites, admin email (#28)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 22m21s
ci / image (push) Successful in 25s
Demonstration plan, phase D1 (registry side). The portal's Settings/Users page renders design fixtures today and its "Invite member" button posts to a route that does not exist, because the registry had no membership surface.

**`GET /v1/tenants/{id}/members`** lists the tenant's Keycloak organization members — user id, email, first/last name, `org_roles`, `enabled`, `created_at`. A tenant whose organization was never created (sales-led) answers an empty list rather than an error.

**`POST /v1/tenants/{id}/invites`** `{email, first_name?, last_name?, role?}` creates the Keycloak user if missing, adds the organization member (KC 26: the member body is the bare user id), writes the tenant-context user attributes, sends the same execute-actions mail the first admin gets, and audits `user.invited` with the caller as actor. Idempotent: an existing member answers `200 {status:"member"}` and sends no mail; a new one `202 {status:"invited"}`.

**Scope.** A user token may only touch its own tenant — another tenant's id is a 404, never a hint that it exists. Inviting needs the `IT_ADMIN` or `OWNER` org role, so `Principal` now carries the `org_roles` claim and `IsTenantAdmin()`. Service clients stay gated by `AUTHZ_RULES` route groups: members on `tenants.read`, invites on `tenants.write`.

**`admin_email` on the tenant** (migration `0006`, backfilled from the `keycloak.invite_sent` audit trail, and from `keycloak.provision_failed` metadata where the first invite failed) so Settings can show a real contact instead of an em dash. The first `IT_ADMIN`/`OWNER` invite fills it in when it was empty.

**Routing note worth keeping:** `GET /v1/tenants/{id}/members` cannot be registered — Go's ServeMux calls it a conflict with `GET /v1/tenants/by-slug/{slug}`, since both match `/v1/tenants/by-slug/members` and neither pattern is more specific. It is registered as `GET /v1/tenants/{id}/{sub}` instead, which *is* less specific than the by-slug lookup, so the two coexist; anything but `members` answers 404.

`openapi.yaml` documents both endpoints, the `OrgMember`/`Invite` schemas, `admin_email` and a `Forbidden` response.

Verified locally: `go vet ./...`, `gofmt` clean, `go test ./...` green, CI coverage command at **74.3%** (gate 70%).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #28
2026-09-14 08:27:12 +00:00
sharang 209524e5ac feat(erp): always-on ERP link, usage events, outbox, CLI licences (#25)
ci / shared (push) Successful in 14s
ci / image (push) Successful in 28s
ci / test (push) Successful in 22m28s
2026-09-12 08:35:13 +00:00
sharang 2ea49be29d feat(m-mig-5): products table, entitlement check, tenant ladder, per-client authz (#23)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m58s
ci / image (push) Successful in 56s
2026-09-12 07:38:47 +00:00
sharang 9138731eea feat(keycloak): M4.3 — Admin API adapter + claim resolver
ci / shared (push) Successful in 5s
ci / test (push) Successful in 1m32s
ci / image (push) Has been skipped
internal/keycloak Adapter (HTTPAdapter + Mock). POST /v1/tenants now provisions a KC organization + IT_ADMIN invite when admin_email is set; KC failures emit keycloak.provision_failed but don't roll back. POST /v1/internal/keycloak/claims resolves the current claim bundle for any (tenant_id|tenant_slug|user_attrs.*) lookup. Mock used in tests + when KEYCLOAK_ADMIN_URL is empty. HTTPAdapter tested against an in-process stub KC (httptest.Server).

Refs: M4.3
2026-05-19 11:51:09 +00:00
sharang ffab866c87 feat(api): M4.2 — REST surface + pgx Postgres store + OpenAPI 3.1
ci / shared (push) Successful in 6s
ci / test (push) Successful in 1m15s
ci / image (push) Has been skipped
Full M4.2 deliverable: 16 endpoints (tenants CRUD + lifecycle, catalog, entitlements, API keys with argon2 hashing, audit append + filter), Store interface with pgx-backed Postgres + in-memory parallel implementations exercised by the same eachStore harness, openapi.yaml at 3.1 with kin-openapi contract test. M4.3 adds auth.

Refs: M4.2
2026-05-19 10:51:59 +00:00