Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.emergence.ai/llms.txt

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

Security Overview

Security is embedded into every layer of CRAFT. The security model is built on four pillars: authentication (who you are), authorization (what you can do), secrets management (protecting credentials), and multi-tenant isolation (keeping organizations separate).

Security Architecture

Technology: Keycloak with multi-realm JWT and OIDC/PKCEKeycloak provides the identity layer for the entire platform. Each organization is a separate Keycloak realm, providing complete identity isolation between tenants.
FeatureDetails
ProtocolOpenID Connect (OIDC) with PKCE for browser clients
Token formatJWT containing org_id (from realm), groups, and user claims
Multi-realmEach organization = one Keycloak realm (realm ID = org ID)
SSO supportEnterprise SSO via SAML or OIDC identity provider federation
Session managementToken refresh, revocation, and session timeout policies
The project_id is never stored in the JWT. It is passed via the X-Project-ID HTTP header or as a path parameter, allowing users to switch project context without re-authenticating.

Dual Authorization Pattern

The platform enforces authorization through a dual pattern that combines database filtering with OpenFGA checks:
Operation TypeDatabase FilterOpenFGA Check
List operationsFilter by auth.org_id + project_idrequire_permission() for project access
Get-by-ID operationsNot neededrequire_permission() handles authorization
Create operationsStamp auth.org_id on resourcerequire_permission() for project write access
Delete operationsNot neededrequire_permission() for resource delete access
This dual pattern prevents two classes of vulnerabilities: (1) listing resources across organizations (database filter) and (2) accessing specific resources without permission (OpenFGA check).

Authentication Flow

1

User Login

The user authenticates via OIDC/PKCE flow against their organization’s Keycloak realm. The browser receives a JWT token containing org_id and group memberships.
2

API Request

The client includes the JWT in the Authorization: Bearer <token> header and the active project in the X-Project-ID header.
3

Token Validation

The Governance service validates the JWT signature, expiry, and issuer. It extracts org_id from the realm claim.
4

Permission Check

OpenFGA evaluates the user’s relationship to the requested resource. Computed permissions are resolved at query time based on role inheritance.
5

Request Processing

If authorized, the request proceeds with the authenticated context. Database queries are scoped to org_id and project_id.

Network Security

ControlImplementation
SSRF protectionWebhook and data connection endpoints validate target URLs against allowlists
HMAC signaturesWebhook payloads will be signed with HMAC for integrity verification (planned — not yet released)
TLSAll inter-service communication uses TLS in production
Private networkingCloud deployments use private VPC networking; self-managed clusters should use equivalent network segmentation
Firewall rulesTerraform-managed ingress/egress rules

Observability and Audit

The platform provides comprehensive observability for security monitoring:
ComponentTechnologyPurpose
TracesOpenTelemetry + TempoDistributed request tracing across services
MetricsOpenTelemetry + MimirService health, latency, and throughput metrics
LogsOpenTelemetry + LokiStructured logging with correlation IDs
DashboardsGrafanaVisualization and alerting for all telemetry
All telemetry is exported via the OTLP (OpenTelemetry Protocol) standard — a vendor-neutral protocol compatible with any OTLP-capable backend. You choose your observability stack; the Grafana LGTM bundle (Loki, Grafana, Tempo, Mimir) is included by default but never required.

Security Best Practices

  • Enable TLS for all ingress and inter-service communication
  • Configure Keycloak password policies and brute-force detection
  • Set up regular secret rotation (Infisical rotation policies or ESO + Stakater Reloader)
  • Monitor OpenFGA permission check latency and error rates
  • Review audit logs for unauthorized access attempts
  • Use private networking for database and cache connections
  • Never implement permission checks directly — always use require_permission()
  • Always use auth.org_id from JWT, never from request parameters
  • Never store secrets in configuration files or environment variables in source control
  • Use the Governance SDK for all authentication and authorization operations
  • Validate webhook signatures before processing events (when webhook feature is released)
  • Use parameterized queries to prevent SQL injection (enforced by SQLAlchemy ORM)

Next Steps

Authentication

Deep dive into Keycloak configuration and OIDC flows.

Data Classification

Understand data classification and handling policies.

Network Security

Learn about network-level security controls and firewall configuration.

RBAC Configuration

Step-by-step guide for configuring roles and permissions.