Skip to content

Entitlements & Security

The Security Layer protects every aspect of the Layerr system, from API keys to workspace isolation to regulatory compliance. It ensures that secrets never leak, tenants never cross boundaries, and guardrails prevent misuse.

SubsystemPurposeKey Files
Secrets ManagerEncrypted storage for API keys and credentialssecurity/secrets/
Credential RotationAutomatic rotation of provider API keyssecurity/rotation/
Access ControlPermission engine for workspace resourcessecurity/access/
Tenant IsolationMulti-tenant workspace boundary enforcementsecurity/tenancy/
Gateway SecurityToken validation, audit logging, rate limitingsecurity/gateway/
GuardrailsContent policy enforcement and PII detectionguardrails/evaluator.ts
Entitlements EngineLicense and feature-gatingentitlements/engine.ts

API keys and credentials are stored encrypted (security/secrets/store.ts):

FeatureImplementation
Encryption at restAES-256 via security/secrets/manager.ts
Key derivationPBKDF2 with workspace-specific salts
RedactionAutomatic redaction in logs (security/secrets/redact.ts)
Access auditEvery key access is logged

The rotation engine (security/rotation/engine.ts) handles:

FunctionPurpose
CredentialRotationEngineOrchestrates scheduled key rotation
rotateKey()Rotates a single provider key
detectStaleKeys()Identifies keys approaching expiry
Provider TypeRotation Interval
Cloud providers (OpenAI, Anthropic)90 days
Self-hosted (Ollama, local)Disabled
Enterprise contractsConfigurable

The permission engine (security/access/engine.ts) enforces:

PermissionDescription
workspaces:readView workspace configuration
workspaces:writeModify workspace settings
providers:createAdd new provider connections
providers:deleteRemove provider connections
traces:readView execution traces
traces:deleteDelete execution traces
billing:readView billing and cost data
billing:writeModify budget settings
admin:allSuper admin access

Workspace isolation is enforced at multiple levels (security/tenancy/):

LevelEnforcement
DatabaseRow-level security per workspaceId
RuntimeContext injection prevents cross-tenant lookups
CacheTenant-scoped cache keys
LogsWorkspaceId tagged on every log entry

The guardrails evaluator (guardrails/evaluator.ts) checks requests for:

CheckAction
PII detectionBlock or redact if PII detected
Sensitive dataSanitize sensitive data in traces (sanitizeSensitiveData())
Content policyEnforce workspace content policies
Rate limitingPer-workspace and per-provider rate limits

The entitlements engine (entitlements/engine.ts) manages:

FeatureControl
License activationValidates license keys
Feature gatingEnables/disables features based on tier
Snapshot managementLicense snapshot and validation
FileWhat It Does
security/secrets/store.tsEncrypted credential storage
security/secrets/manager.tsKey derivation and encryption
security/secrets/redact.tsLog redaction
security/rotation/engine.tsKey rotation orchestration
security/rotation/detector.tsStale key detection
security/access/engine.tsPermission evaluation
security/tenancy/context.tsTenant context injection
security/gateway/middleware.tsGateway token validation
security/gateway/audit.tsAccess audit logging
guardrails/evaluator.tsContent policy and PII checks
entitlements/engine.tsLicense and feature entitlements
  1. Execution Engine → reads API keys from Secrets Manager
  2. Provider Registry → triggers rotation on credential expiry
  3. Workspace Profiles → reads tenant context for isolation
  4. Economics → respects feature entitlements (e.g., simulation access)
  5. All API routes → pass through gateway middleware for auth and audit