Intry

Authentication

WorkOS, Clerk, JWT, and Unkey across Intry surfaces.

Overview

Intry uses different auth mechanisms per surface. ADR-004 target: Clerk everywhere; WorkOS is being retired but still active for some admin flows.

Deep runbook: docs/AUTH_ARCHITECTURE.md in the monorepo.

Three authentication paths (current)

Admin users (WorkOS + Clerk migration)

AspectDetail
WhoPlatform admins, property managers, staff
LoginWorkOS SSO (legacy cookie wos-session) or Clerk Organizations via intry-admin gateway
Routes/api/admin/*
MiddlewarerequireAdmin() in src/middleware/workosAuth.ts; Clerk bearer for comms routes

Residents — mobile app

AspectDetail
LoginClerk or legacy email + password (POST /registration/login)
AuthJWT Bearer on subsequent requests
Routes/api/v1/*, /access/*, /devices/*

Residents — web portal

AspectDetail
LoginClerk only (sign-in / sign-up)
Backend exchangePOST /api/v1/auth/clerk-session — Clerk session token → Core JWT (match by email)
RoutesSame JWT-protected /api/v1/* as mobile

Machine / automation auth

ClientMethod
MCP, CI, scriptsUnkey API key: Authorization: Bearer <key>
ScopesLeast-privilege scopes on /api/admin/api-keys

See docs/AGENT_UNKEY_KEYS.md and docs/UNKEY_AND_API_AUTHENTICATION.md.

Webhook auth

ProviderVerification
TwilioX-Twilio-Signature HMAC
TelnyxEd25519 {timestamp}|{body}
StripeStripe-Signature header
ClerkverifyWebhook() from @clerk/backend/webhooks

Target state (ADR-004)

SurfaceClerk primitiveRole source
intry-adminClerk Organizationorg:role session claim
intry-portalClerk UserUser metadata
intry-appClerk UserUser metadata
intry-core APIClerk session token@clerk/backend verify

Middleware target names: requirePlatformAdmin, requireOwner, requireResident — not yet fully implemented; use current middleware until migration completes.

Middleware file map

FilePurpose
src/middleware/workosAuth.tsAdmin WorkOS session
src/middleware/jwtAuth.tsResident JWT (requireAuth)
src/lib/clerkBearerAuth.tsClerk token verification
src/routes/clerk-webhook.tsUser/org sync webhooks

Last verified: 2026-06-21 (commit 293c4a7)

On this page