Explore documentation

Authentication

Credentials, session protections, and SMART on FHIR in Esus

Credential Types

CredentialHeaderLifetimeNotes
Console JWTAuthorization: Bearer (or httpOnly cookie)Access token 900 s; refresh token 7 daysEach refresh rotates the refresh token. Reusing an old one revokes all of that user’s tokens.
API keyX-API-Key: clientId:secretUntil revoked or until its expiresAtFor server-to-server use only. Authorization depends only on its scopes.
SMART tokenAuthorization: Bearer3600 s, no refreshNarrows 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/login and POST /auth/mfa/verify allow 10 requests per minute.
  • MFA (TOTP): when MFA is enabled, POST /auth/login returns { "mfaRequired": true, "mfaToken": "…" }. Session tokens are issued only after POST /auth/mfa/verify with 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/sessions lists the user’s active sessions. DELETE /auth/sessions/:sessionId revokes one, and POST /auth/logout-all revokes them all.

API Keys

  • The secret is shown only once, when the key is created or rotated.
  • Scopes follow Resource.action with read, create, update, delete, Resource.*, or a bare *. Resource.write grants create, update, and delete. *.read is invalid.
  • API keys skip the consent check and the role policies: only their scopes apply.
  • POST /api-keys/:id/rotate creates a new key, with a new id, clientId, and secret. The old key keeps working for graceHours (24 h by default, 168 h maximum). Send graceHours: 0 to revoke it immediately.
  • The rateLimit field is a per-key cap in requests per minute. The effective limit is the lower of the key’s rateLimit and 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.

AspectBehavior
Flowauthorization_code only, with PKCE S256 required
Client authenticationclient_secret_post (confidential apps) or public apps
LaunchPOST /smart/launch with { client_id, patient } returns { launch, expires_in: 600 }. The launch is single-use
Authorization codeValid for 10 minutes, single-use
Access token3600 s. Includes patient only when a launch was used. No refresh token, no id_token
Unsupported scopesopenid, fhirUser, offline_access
Scopespatient/* 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 at GET /v1/integration/connection. Managed terminology catalogs also accept delegated access with user/CodeSystem.rs.
  • patient/ scopes are pinned to the launched patient. Without a launch, they give no access to patient data.
  • $everything requires a *.read scope.
  • Emergency override does not work with SMART tokens.
  • Only an organization admin (or an API key with the SmartApp.create scope) can register apps (POST /smart/apps).