Security
Authentication
Credentials, session protections, and SMART on FHIR in Esus
Credential Types
| Credential | Header | Lifetime | Notes |
|---|---|---|---|
| Console JWT | Authorization: Bearer (or httpOnly cookie) | Access token 900 s; refresh token 7 days | Each refresh rotates the refresh token. Reusing an old one revokes all of that user’s tokens. |
| API key | X-API-Key: clientId:secret | Until revoked or until its expiresAt | For server-to-server use only. Authorization depends only on its scopes. |
| SMART token | Authorization: Bearer | 3600 s, no refresh | Narrows the user’s permissions; valid on supported FHIR interactions and the connection check |
For the full step-by-step flow (login, refresh, API keys, and SMART), see Getting Started → Authentication.
Console Login Protections
- Passwords: at least 12 characters, with an uppercase letter, a lowercase letter, a number, and a symbol. When you set a password, Esus checks it against Have I Been Pwned using k-anonymity. If that service is down, the check does not block the change.
- Hashing: passwords are hashed with Argon2id (19 MiB, t=2, p=1).
- Lockout: 5 failed attempts lock the account for 15 minutes, and the owner gets an email.
- Rate limit:
POST /auth/loginandPOST /auth/mfa/verifyallow 10 requests per minute. - MFA (TOTP): when MFA is enabled,
POST /auth/loginreturns{ "mfaRequired": true, "mfaToken": "…" }. Session tokens are issued only afterPOST /auth/mfa/verifywith a TOTP code or one of the 10 recovery codes. - Inactivity: after 8 hours without activity, the refresh token stops working and the user must log in again.
- Sessions:
GET /auth/sessionslists the user’s active sessions.DELETE /auth/sessions/:sessionIdrevokes one, andPOST /auth/logout-allrevokes them all.
API Keys
- The secret is shown only once, when the key is created or rotated.
- Scopes follow
Resource.actionwithread,create,update,delete,Resource.*, or a bare*.Resource.writegrantscreate,update, anddelete.*.readis invalid. - API keys skip the consent check and the role policies: only their scopes apply.
POST /api-keys/:id/rotatecreates a new key, with a newid,clientId, andsecret. The old key keeps working forgraceHours(24 h by default, 168 h maximum). SendgraceHours: 0to revoke it immediately.- The
rateLimitfield is a per-key cap in requests per minute. The effective limit is the lower of the key’srateLimitand your plan’s limit; it can lower the plan limit but never raise it.
SMART on FHIR
SMART is turned on with SMART_ENABLED, which is enabled on api.esus.health. Discovery is available at /.well-known/smart-configuration.
| Aspect | Behavior |
|---|---|
| Flow | authorization_code only, with PKCE S256 required |
| Client authentication | client_secret_post (confidential apps) or public apps |
| Launch | POST /smart/launch with { client_id, patient } returns { launch, expires_in: 600 }. The launch is single-use |
| Authorization code | Valid for 10 minutes, single-use |
| Access token | 3600 s. Includes patient only when a launch was used. No refresh token, no id_token |
| Unsupported scopes | openid, fhirUser, offline_access |
| Scopes | patient/* and user/*, in v1 (.read, .write) or v2 (.rs, .cruds, …) form |
SMART security rules:
- The token never exceeds the user’s real roles and permissions: the scope can only narrow them.
- It works for supported interactions on
/fhir/<Resource>and the connection check atGET /v1/integration/connection. Managed terminology catalogs also accept delegated access withuser/CodeSystem.rs. patient/scopes are pinned to the launched patient. Without a launch, they give no access to patient data.$everythingrequires a*.readscope.- Emergency override does not work with SMART tokens.
- Only an organization admin (or an API key with the
SmartApp.createscope) can register apps (POST /smart/apps).