Skip to content

API Authentication

EaseLab uses JWT bearer tokens for API authorization and HTTP-only cookies for refresh token rotation.

Token configuration

SettingDefaultLocation
AccessTokenMinutes15appsettings.jsonJwt
RefreshTokenDays7appsettings.jsonJwt
IssuerEaseLabApiJWT iss claim
AudienceEaseLabClientJWT aud claim

Auth endpoints

MethodEndpointAuthDescription
POST/auth/registerPublicRegister new lab
GET/auth/lab-slug-previewPublicPreview URL slug
POST/auth/loginPublicSign in
POST/auth/verify-2faPublicComplete 2FA login
POST/auth/refreshCookieRotate tokens
POST/auth/logoutCookieRevoke refresh token
POST/auth/forgot-passwordPublicRequest reset email
POST/auth/reset-passwordPublicSet new password
POST/auth/verify-email-otpPublicVerify email via OTP
POST/auth/resend-email-otpPublicResend OTP
POST/auth/confirm-emailPublicVerify via email link
POST/auth/impersonate/exchangePublicExchange impersonation code

Mobile auth (/auth/mobile)

MethodEndpointNotes
POST/auth/mobile/loginReturns refresh token in body
POST/auth/mobile/verify-2faMobile 2FA completion
POST/auth/mobile/refreshBody: { "refreshToken": "..." }
POST/auth/mobile/logoutRevokes refresh token

Login request / response

Request:

json
{ "email": "[email protected]", "password": "..." }

Success response:

json
{
  "accessToken": "eyJ...",
  "expiresAt": "2026-06-26T10:15:00Z",
  "user": {
    "id": "...",
    "email": "[email protected]",
    "tenantId": "...",
    "isTenantAdmin": true
  }
}

Set-Cookie: refresh_token (HttpOnly, Secure in production, SameSite=Lax).

JWT claims

ClaimDescription
subUser ID
emailUser email
tenant_idTenant GUID (absent for platform admins)
rolePlatform or tenant role names

Refresh flow

  1. Client detects 401 or approaching token expiry.
  2. POST /auth/refresh with refresh cookie (no body).
  3. Server revokes old refresh token, issues new access + refresh tokens.
  4. On invalid/expired refresh: 401, cookie cleared.

Profile and 2FA (/me)

MethodEndpointDescription
GET/meCurrent user profile
PUT/meUpdate profile
PUT/me/passwordChange password
GET/me/2fa2FA status
POST/me/2fa/setupBegin TOTP setup
POST/me/2fa/enableConfirm and enable
POST/me/2fa/disableDisable 2FA

Analyzer API key auth

Analyzer devices authenticate with the X-Analyzer-Key header on /integrations/v1/* routes. See Analyzer Integration.

Security headers

Clients should:

  • Store access tokens in memory only (not localStorage in production).
  • Send credentials (credentials: 'include') for refresh requests.
  • Use HTTPS in all non-development environments.

Ease Lab — Cloud Pathology Lab Management