Skip to main content

Documentation Index

Fetch the complete documentation index at: https://brama.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Principle: defense in depth

Cross-tenant data leak — product-killer. Тому isolation у Brama працює на 4 шарах:
1

Supabase RLS (Row Level Security)

Усі tenant-scoped tables у нашому Postgres мають RLS policies що filter за tenant_id з JWT. Anon/authenticated client не може прочитати рядок іншого tenant’а — навіть якщо SQL injection happens.
2

Context propagation у Go MCP server

Tenant ID injecting у context.Context middleware’ом на початку запиту. SDK constructors отримують token per request — ніколи через globals. Не існує shared mutable state з tenant credentials.
3

Idempotency keys per tenant

Write tool calls передають idempotency_key. Brama зберігає у Supabase з (tenant_id, key) композитним unique constraint. Tenant_A не може hijack’нути idempotency key tenant_B.
4

Audit trail

Кожен tool call logging’ується з tenant_id у Sentry breadcrumbs. Можна post-hoc верифікувати що X викликав Y.

Service-role usage discipline

Server actions у brama-app/apps/admin мають privileged Supabase client (createServiceRoleClient) що bypasses RLS. Це необхідно для:
  • Stripe webhooks (нема user JWT, треба identify tenant за customer_id)
  • Tenant onboarding (create row до того як user має tenant_id у JWT)
  • Cross-tenant admin tasks (super-admin scope для billing reconciliation)
Захист: ESLint rule блокує process.env.SUPABASE_SECRET_KEY access поза server-only paths (server.ts, route.ts, actions/, middleware.ts, instrumentation*.ts). Build-time 'server-only' import directive — secondary guard. Convention: кожна server action що використовує service_role MUST manually verify tenant ownership через tenant_id filter перш ніж mutate.

Не покрите Brama

  • Encryption at rest для tenant tokens — поки Supabase default (postgres encrypted volume). Field-level encryption через pgsodium — Phase 2.
  • Cross-tenant analytics aggregation — використовуємо service_role у server-only paths. Будь-який query MUST включати explicit tenant filter.
  • Audit log search UI — поки тільки через Sentry. Native admin UI search — backlog.