Skip to Content
DocumentationSecurityAuth & RBAC

Security

Authentication, authorization, and security architecture for GoTamil API.

Authentication Overview

GoTamil API implements defense-in-depth authentication with four distinct mechanisms for different access patterns.

LayerMechanismEndpoints
User APIOIDC Bearer tokens/v1/proofread, /v1/essay-critique, /v1/operations
Admin APIOIDC with role verification/v1/admin/*
Operator APIIdentity verification/v1/operator/*, /v1/internal/*
WorkerInternal task auth (token/OIDC)/internal/tasks/*
Admin ConsoleSupabase OAuth (Google Sign-In)Console UI

Role-Based Access Control

Five roles govern access across the platform:

RoleScopeAccess Level
tenant_adminTenantFull management — BYOK, certification, onboarding, dashboard
tenant_viewerTenantRead-only — onboarding status, dashboard
service_integrationTenantService account access for AI endpoints
gotamil_operatorPlatformOperator — invites, tenants, admin members
unknownDenied

Roles are extracted from JWT claims. The API checks multiple claim paths: gotamil_roles, roles, role, app_metadata.gotamil_roles, app_metadata.roles.

Tenant Isolation

  • Every API request is scoped to the tenant_id from the JWT
  • Operations can only be polled by the tenant that created them
  • Row Level Security (RLS) is enabled on all tenant data tables
  • Supabase anon and authenticated privileges are revoked on API tables

Secrets Management

All sensitive values are stored in Google Cloud Secret Manager:

SecretPurpose
Database URLPostgreSQL connection string
OIDC JWKSPublic key set for token validation
BYOK credentialsPer-tenant Gemini API keys
Invite token secretHMAC signing key for invites
Internal task tokenWorker authentication

Idempotency

Critical mutation endpoints support idempotent requests via the Idempotency-Key header:

  • Scope: unique per (tenant_id, endpoint, idempotency_key)
  • Reservation TTL: 120 seconds for in-progress requests
  • Conflict: 409 if same key is being processed by a different request

Audit Trail

Every significant mutation is recorded in the tenant_audit_events table with:

  • Event type and result
  • Actor subject (user or system ID)
  • Request ID and operation ID
  • Actor email and roles
  • Timestamp

See Audit Logging in the feature spec for the complete event type list.

Production Safety Guards

The API validates critical security configuration at startup:

  • Dev tokens are blocked in production
  • JWKS key set is required
  • Internal task tokens must not use default values
  • Invite secrets must meet minimum length
  • Console URL must use HTTPS
  • Internal task auth must use OIDC (not shared token)
Last updated on