Open Enterprise
Browse topics
DocumentationDeployment

Security and deployment

The threat model (docs/threat-model.md) summarizes what these protections defend against and what stays with the deployment.

The 2026-11-15 security scan (docs/security-findings-2026-11-15.md) records findings for the scanned repository snapshot.

Trust boundaries

The browser is untrusted. The application backend holds organization-scoped service credentials and controls trusted external audit actor references. The runtime owns canonical mapping, authorization, and session validation. The configured OIDC issuer proves upstream identities. With local accounts, the runtime itself verifies passwords and second factors. PostgreSQL holds canonical data and must remain inside the trusted deployment boundary.

The runtime authenticates capability operations with bearer credentials. The SSF push endpoint instead requires a signed SET from its configured transmitter. Service credentials list explicit organization IDs and operation scopes. The runtime does not accept wildcard organization scopes. Each user session binds its canonical user ID and organization ID. The runtime ignores identity and tenant headers from callers.

API keys, invitation tokens, runtime session tokens, login handles, exchange codes, local challenge tokens, account-page sessions, and onboarding tokens persist as SHA-256 hashes. Local passwords persist as Argon2id hashes, recovery codes as SHA-256 hashes, and TOTP seeds sealed with AES-256-GCM under the local key. Their generated bearer values contain 256 random bits. OIDC client secrets come from environment variables. Transient login records contain nonce and PKCE material until expiration and cleanup. The database requires confidential access, encrypted disks, and protected backups.

The example stores the runtime token with AES-256-GCM encryption inside its backend cookie session record. Its token encryption key derives from the random application session secret with a distinct context label. The browser receives an opaque HttpOnly cookie with SameSite=Lax. HTTPS application origins require Secure cookies. The example verifies an exact Origin header and a session-bound CSRF token for browser state changes.

Backend integrations use explicit bearer credentials. Native administration and operator browsers use short-lived HttpOnly cookies with same-origin and CSRF checks. Administration requests recheck the parent session and its current sign-in policy. The login flow also verifies upstream state, nonce, PKCE, and the application exchange verifier. The application verifies its own login state before exchange. Exact redirect allowlists prevent redirects to caller-selected origins.

Database queries use bound parameters. Request bodies default to 256 KiB and cannot exceed the configured maximum of 1 MiB. Oversized JSON requests return HTTP 413 with the common JSON error envelope. JSON requests without a JSON content type return HTTP 415. SCIM errors use the SCIM envelope. SSF push errors use RFC 8935 error fields. Request timeouts default to 15 seconds. Database statements and upstream provider requests have 10-second limits. Logs exclude request query strings, authorization headers, upstream tokens, and SQL parameters.

Prepare a deployment

  1. Create a deployment-specific YAML configuration.
  2. Remove development: true.
  3. Set an HTTPS public runtime URL.
  4. Configure a trusted OIDC issuer and exact HTTPS callback URI.
  5. Create a PostgreSQL database with confidential network access.
  6. Apply the migrations with an operator-controlled database role.
  7. Give the runtime only the required access to its database.
  8. Give the application a separate database role.
  9. Generate new service keys with enterprise-runtime keygen.
  10. Put each SHA-256 digest in its configured environment variable.
  11. Put each corresponding bearer key in the authorized application backend.
  12. Restrict each credential to its organization IDs and operation scopes.
  13. Supply a random application session secret with at least 32 characters.
  14. With local accounts, generate the local key with enterprise-runtime keygen, keep it with the other master keys, and configure SMTP with starttls or tls. Set server.trusted_proxies to the ingress addresses, so throttles count real client addresses.
  15. Configure TLS termination, request limits, and network rate limits at the deployment ingress.
  16. Protect database backups and the secret environment.
  17. Run the security and browser tests against the deployment.

By default, the runtime applies embedded migrations during startup. In production, run enterprise-runtime migrate with a separate migration role and set storage.migrate_on_startup: false. The runtime role then needs no schema privileges. It still reads the migration history at startup, so it needs SELECT on _sqlx_migrations. See run the runtime and upgrade the runtime.

The Fastify SaaS example is a development reference. Its default listener uses HTTP. A production application must configure trusted TLS termination and proxy behavior before it requires Secure cookies. The runtime itself provides plain HTTP behind a trusted TLS ingress.

Bootstrap an organization

The bootstrap command is a trusted operator action with direct database access. It creates an organization and an owner invitation without password storage. It requires these environment variables:

Variable Purpose
BOOTSTRAP_ORGANIZATION_ID Stable canonical organization ID
BOOTSTRAP_ORGANIZATION_NAME Organization display name
BOOTSTRAP_ORGANIZATION_SLUG Unique organization slug
BOOTSTRAP_OWNER_EMAIL Verified email required for the initial owner
BOOTSTRAP_INVITATION_TOKEN Random token of at least 32 characters for secure delivery
Shell
enterprise-runtime bootstrap /path/to/config.yaml

The command does not print the invitation token. An existing token hash makes the command idempotent. An expired, unaccepted invitation requires a new random token. The owner accepts the token after standard OIDC authentication.

Without an identity provider, enterprise-runtime enroll <config> --initial-owner creates the organization if needed and prints a single-use link where the first owner chooses a password. The setup fails if the organization already has an owner, and nobody becomes an owner by visiting first.

Service credentials with organizations:create can also create explicitly reserved organization IDs over HTTP. The creator then delivers an invitation through its authorized service scope. Self-service owner onboarding accepts only unreserved IDs, including when its backend can provision a reserved organization directly. User sessions cannot create organizations or grant permissions outside their current organization.

Current boundaries

The local RBAC provider does not enforce resource ACLs, ownership rules, or domain invariants. Applications must enforce those rules before their business operations. Built-in roles come from trusted deployment configuration and bootstrap operations. The full v0.3 permissions selection adds authenticated custom-role, ACL, relationship, and policy APIs. Membership and invitation writes recheck user authority under the organization lock. A queued mutation cannot use membership or role permissions revoked before it obtains that lock.

Local logout revokes runtime access only. Upstream sessions, refresh tokens, and global IdP logout remain outside this release. The runtime does not retain upstream access tokens or refresh tokens.

Direct audit writes are durable but separate from application transactions. The reference application commits pending audit input with each business change and retries delivery through its own outbox. Its retry limits and recovery contract are documented in the events guide. Operators must review deployment capacity, TLS, backup recovery, and credential rotation for their environment.

Enterprise provisioning and revocation

Directory credentials are separate from service keys and restricted to one directory and organization. Startup rejects duplicate directory credentials and credentials shared with services. Use enterprise-runtime keygen to generate each key; keep only its digest in the runtime environment. Rotate the digest and update the directory client together. Directory endpoints require TLS in production.

Only an administrator-controlled, signed immutable identifier can link provisioning and login. SAML broker configuration must verify customer signatures and restrict account linking and editable attributes. The reference Keycloak adapter does not trust email addresses from customer identity providers. Brokered SAML logins therefore carry no verified email, and the broker cannot link them to an existing account through a trusted email. A signed upstream_idp claim proves the configured authentication source. A separate recovery owner must remain outside directory management.

SCIM deactivation invalidates sessions and pending exchanges in its transaction. CAEP acceptance commits a denial record with the durable inbox before returning HTTP 202. The example performs uncached runtime session checks on every protected request. An operation already in progress may finish; revocation does not undo completed application writes.

SSF management credentials remain in the runtime environment and go only to endpoints from trusted discovery. The receiver disables redirects and validates SET signatures, issuer, audience, event type, and subject scope. Each configured receiver uses a distinct transmitter issuer and audience pair to prevent replay across organizations. Existing sessions without login-origin metadata cannot be matched by CAEP. Revoke these sessions when enrolling an existing connection. Do not delete revocation or deduplication records with ordinary audit retention; doing so can allow old events or sessions to return. See security signals for the supported protocol profile and operational behavior.

Advanced authorization boundary

The full permissions deployment registers canonical resources and enforces active membership before external decisions. Trusted backends supply subject and resource attributes through scoped credentials. Users cannot assert service attribute provenance or MFA. Missing, stale, untrusted, or invalid attributes deny applicable policies. Explicit denials and required conditions override every grant path.

Keep OPA's data API private and use distinct PDP decision and synchronization credentials. The AuthZEN adapter validates discovery, endpoint origins, timeouts, response bindings, and declared consistency capabilities. The database revision barrier rejects a remote allow if access changes before the final check. There is no allow fallback during an outage. An operation already authorized may finish; application transactions remain outside the runtime's transaction boundary.

The recovery owner retains local policy-management authority during a PDP outage. This trusted control-plane authority does not permit business checks to skip the PDP. Review full bundles before activation or rollback: they include local resources, grants, attributes, and relationships. Managed directory status, current membership, and session revocations remain live gates across rollback. See permissions for supported limits, synchronization recovery, and snapshot memory retention.

Administration boundaries

The portal backend holds its exchange-only service credential and encrypts the scoped runtime credential in its database session. Each mutation checks current authority, organization, original operation scope, exact Origin, and CSRF token. A parent-session revocation or deprovisioning invalidates portal access on the next check. The child credential grants no generic login or application-session authority.

Customer OIDC secrets use an external 32-byte master key and authenticated encryption bound to organization and reference. Protect this key separately from database backups. Customer-controlled OIDC traffic blocks private destinations outside development mode, including DNS results used during connection. It ignores proxy environment variables, because a proxy would resolve the destination itself. Each customer-managed OIDC issuer has its own callback URL, and the runtime checks the RFC 9207 iss response parameter when present. It refuses a response without iss from an issuer whose discovery metadata sets authorization_response_iss_parameter_supported. An authorization code from one issuer therefore never reaches the token endpoint of another issuer (OAuth mix-up). SAML metadata requires valid signing certificates; the external broker performs protocol signature checks.

Production infrastructure credentials need only the documented identity-provider administration roles and API scope. Keep an independent local recovery owner and protect its identity-provider credentials. The administration guide covers key rotation, DNS leases, activation recovery, and deployment defaults.

Lifecycle delivery

Event feed credentials bind organizations and can restrict exact event types. Subscription mutations and replay recheck current administrator authority and portal operation scope. Lifecycle payloads exclude credentials, provider metadata, and trusted attribute values. They do not reinterpret arbitrary audit submissions as canonical facts.

Webhook delivery signs exact body bytes with the stable event ID and delivery timestamp. Consumers verify signatures and timestamp tolerance before durable receipt. Their own event-ID uniqueness and resource-version ledger provide replay and stale-update protection.

Production delivery rejects private network destinations. These include IPv6 forms that carry a private IPv4 address, and private DNS results at connection time. The HTTP adapter disables proxies and redirects and applies a bounded timeout. Signing keys use authenticated encryption under a separately protected deployment key. The events guide covers secret overlap and master-key rotation.

Local account boundaries

The runtime's sign-in, registration, recovery, and account pages are the only place a local password is typed. Applications never see it, and service credentials cannot read password hashes or TOTP seeds through any API.

Browser state changes on these pages need a CSRF token bound to a cookie, a same-origin Origin or Sec-Fetch-Site, and, for login, the browser that started the flow. Pages send a strict CSP without scripts, X-Frame-Options: DENY, Referrer-Policy: no-referrer, and Cache-Control: no-store. Single-use tokens leave the address bar before the page renders. Responses to registration and reset requests do not reveal whether an address has an account, and unknown addresses verify against a dummy hash.

A registration confirms an address only when its owner opens the link and chooses the password there, so preclaiming someone else's address gives an attacker nothing. Sensitive account changes need a sign-in from the last five minutes, with the second factor when it is on. Password resets, factor recovery, and account disablement end sessions and pending exchanges through the credential epoch.

Logs, audit records, metrics, operator listings, and lifecycle events carry account IDs, email domains, and outcomes, never passwords, codes, links, or sealed values. The test secrets_stay_out_of_records_listings_metrics_and_logs in crates/enterprise-runtime/tests/local_identity.rs searches database rows, operator listings, metrics, and captured logs for every secret its flows used.

Operator credentials can act across organizations. Keep them out of applications, and prefer the CLI, which needs no credential beyond database access. See local accounts and the provider-migration runbook.

OAuth issuer boundaries

The issuer signs tokens for your applications with keys that only the runtime can open. Private signing keys are sealed in PostgreSQL with issuer.secret_key_env, and the key set publishes public keys only. Client secrets and resource introspection secrets are stored as SHA-256 hashes, and authorization codes and refresh tokens as hashes of 256-bit random values.

Every client uses PKCE with S256 and exact redirect matching. The only exception is the RFC 8252 loopback port, which never extends to hosts, paths, or schemes. Authorization responses carry the RFC 9207 iss parameter. Sign-in, organization, and approval pages bind each step to the browser that started it with a cookie and a CSRF token, and send the same strict headers as the account pages.

An access token names one resource and one organization. Resource servers must check its signature, issuer, audience, and type, call introspection, and refuse the request when introspection fails. Introspection and refresh re-check membership, directory state, login policy, security signals, client state, and organization client blocks, so access ends on the next request after any of them changes. Tokens never grant more than the person's current permissions in the application.

Operator credentials with clients:manage, resources:manage, grants:manage, keys:manage, or organizations:manage act for the whole deployment. Organization administrators hold applications:read and applications:write, which reach only their organization's grants and client blocks. The OAuth guide covers key rotation, compromise recovery, and the features the issuer does not support.

Search documentation