Skip to main content

Authentication

Terra uses WorkOS AuthKit for authentication, decoupling identity from the database.

Why WorkOS?

Government agencies often require enterprise SSO (SAML, OIDC) with Azure AD, Okta, or Google Workspace. WorkOS makes this configuration, not code.

Authentication Flow

Session Management

Sessions are stored as encrypted cookies:
Cookie properties:
  • Encrypted with WORKOS_COOKIE_PASSWORD
  • HttpOnly (no JavaScript access)
  • Secure (HTTPS only in production)
  • 7-day expiry

User Sync

On first login, we sync WorkOS user data to user_profiles:

Protected Routes

The middleware checks authentication:

Authorization

Role-based access control

Applicant Identity

Portal user management