GebSecure Docs v0.1.0

Architecture · All ADRs

ADR 0015 — Internal administration platform: separate service, separate identity, no silent tenant access

Architecture decision record — status: Accepted.

Status: Accepted

Context#

EPIC 35 gives GebSecure staff tools to operate the service: organization management, subscriptions, feature flags, support and abuse tooling, health and job monitoring, incidents and system usage. These tools need cross-tenant visibility, which the tenant API and gateway deliberately lack (ADR 0003). The risks are staff credentials being usable against tenant APIs (or the reverse), privilege creep, unaudited or silent access to customer data, and emergency access without accountability.

Decision#

Separate service and console. apps/admin-api is its own process and port (ADMIN_API_PORT), with its own CORS origins, and is the only service besides the worker that is given the owner (system) database connection. The tenant API and gateway still run without it (least-privilege tests build them that way). The staff UI is a separate Vite application, apps/admin-console, on its own origin, talking only to the admin API.

Separate identity. Staff accounts live in the gs_admin schema, on which the runtime role has no privileges. Passwords: ≥ 14 characters, three character classes, no email name or common words, scrypt; five failures lock the account for 15 minutes and raise a security notification. TOTP (RFC 6238) is mandatory: login returns only a single-use, five-minute MFA token (distinct typ/audience), enrollment happens at first sign-in, codes are accepted once per time step. Staff access tokens are EdDSA JWTs from a separate key ring (ADMIN_TOKEN_SIGNING_KEYS, refused if it shares a key id with the tenant ring) with issuer https://admin.gebsecure.com, audience gebsecure-admin and typ gs-staff+jwt; every request re-checks the session (MFA-backed, unrevoked, unexpired) and the account. Tenant verification requires the tenant issuer, audience, typ and key ring, so each side rejects the other's tokens.

Internal RBAC. Roles support, billing_ops, sre, security, admin map to explicit permissions read from the database on each request (not from the token). Authentication and authorization run before request validation; denials are written to the admin audit log.

Administrative audit. Every staff action — including failed sign-ins, denied requests and break-glass attempts — is appended to gs_admin.admin_audit, hash-chained under a lock on the chain head. Triggers reject UPDATE, DELETE and TRUNCATE for every role; /admin/v1/audit/verify recomputes the chain. Actions that affect a tenant are also written to that tenant's own audit trail.

Tenant data access is never silent. Staff see operational metadata without a grant. Reading tenant content requires a support-access grant: requested by a named staff member with a reason (and optional ticket), time-limited (≤ ADMIN_SUPPORT_ACCESS_MAX_HOURS), visible in the tenant's console and audit log, approvable / deniable / revocable by the tenant (organizations can require approval), and checked on every read. Reads go through the tenant-scoped RLS connection, and each read is audited on both sides.

Break-glass. Staff with an operational role present ADMIN_BREAK_GLASS_KEY (constant-time comparison, five attempts per hour) and a reason of at least 20 characters; they receive every staff permission bound to their current session for at most ADMIN_BREAK_GLASS_MAX_MINUTES. Activation and failures create security notifications (and email ADMIN_SECURITY_EMAIL when SMTP is configured); every elevated action carries the break-glass id. Tenant data access under break-glass still creates a labelled, tenant-visible grant (it only skips the tenant's approval step).

Product-facing pieces use narrow SECURITY DEFINER functions scoped to the caller's org (gs_feature_flags_for_org, gs_org_throttle, gs_support_grants_for_org, gs_support_grant_decide, gs_status_incidents_for_org), so the tenant API reads what a tenant may see without privileges on gs_admin. Feature flags evaluate kill switch → deny list → allow list → percentage bucket (md5 of key and org, identical in SQL and TypeScript) → default; product code reads them through a 30-second cache and falls back to code defaults, so a flag outage is safe. Worker loops publish run status to Redis for job monitoring.

Consequences#

  • Operating GebSecure requires an additional deployable (admin API) and static site (admin console), which should be reachable only from the corporate network/VPN; neither is needed by customers.
  • Staff cannot change or delete the admin audit log through any interface; database owners could, so owner credentials stay in the platform team's secret store and the chain head should be exported periodically.
  • Flag and entitlement changes reach product processes within 30 seconds (entitlement changes immediately via the Redis version stamp).