Security
Security Overview
How Esus protects health data, layer by layer
Security Layers in Esus
Each request passes through several independent checks. This section explains each one and what it does not cover.
| Layer | What Esus does |
|---|---|
| Authentication | Console JWT sessions (15 min access token + refresh token), API keys (X-API-Key), and SMART on FHIR tokens |
| Tenant isolation | Each organization’s data is isolated with PostgreSQL Row-Level Security; a token from one organization cannot see another’s data |
| Authorization | Permissions (Resource.action) plus resource policies (ABAC); patient consent is checked for PHI |
| Audit logging | PHI access and denied requests are recorded in a hash-chained audit log |
| Encryption | Selected PHI fields (names, contact details, identifiers, clinical free text) are encrypted with AES-256-GCM before storage |
| Integrity | Resource versions, optional If-Match (412 on conflict), and _history |
FHIR Resources Related to Security
| Resource | Use in Esus |
|---|---|
| Consent | An active consent with scope treatment unlocks PHI access for non-admin users |
| Provenance | Records where data came from. Your app creates it; Esus does not generate it automatically |
| CapabilityStatement | GET /fhir/metadata describes what the server supports |
Esus does not expose the audit log as a FHIR
AuditEventresource. Query it through the admin API: see Audit Logging.
Headers
Authenticate each request with one of these headers:
Authorization: Bearer <token>
X-API-Key: <clientId>:<secret>
For FHIR request bodies, use Content-Type: application/fhir+json; application/json is also accepted.
Transport Protections
- HTTPS only. The API sends
Strict-Transport-Securitywithpreload. - Console session cookies are
httpOnly,Secure, andSameSite=Lax, and use the__Host-prefix. - A request that changes data with a session cookie also needs
X-Requested-With: XMLHttpRequest,Authorization, orX-API-Key. This protects against CSRF. - Rate limits are applied by IP. Login endpoints have stricter limits. When exceeded, the API returns
429withRetry-After.
Threat Model
| Threat | Mitigation | Limitation |
|---|---|---|
| Unauthorized access | Authentication, RLS, ABAC | A valid credential grants everything its permissions allow: protect it |
| Database leak | Field encryption + HMAC indexes | Not every column is encrypted (for example, codes and numeric values) |
| Log tampering | Keyed HMAC chain over each row | Tampering is detected, not prevented |
| Access without consent | Consent check on PHI | Does not apply to admins, API keys, or emergency override |