Skip to main content

Authentication Model

Three-Tier Model​

Tier 1: Web UI sign-in​

Each install signs people in one of two ways, chosen per install with AUTH_MODE: through Clerk (the default), or through the organization's own identity provider over OpenID Connect (OIDC mode). In both modes ProjectAchilles never handles a password, MFA or account recovery.

Clerk mode​

All web routes require Clerk JWT authentication.

  • Social login (Google, Microsoft, GitHub)
  • Email/password authentication
  • Short-lived tokens with automatic refresh
  • Session isolation per user

Permissions come from a role (admin, operator, analyst or explorer) in each user's Clerk public metadata, which the session token carries as the metadata claim. A user with no role is read-only (explorer). When the claim isn't configured, the backend looks the role up in Clerk for browser sessions only (cached for a minute). Setup: Clerk Setup.

OIDC mode​

People sign in at the organization's identity provider (authorization code flow with PKCE, state and nonce), under its own MFA and policies. Setup: OIDC Sign-in.

  • Server-side session, one cookie. After sign-in the backend creates a session row and sets __Host-achilles_session (HttpOnly, Secure, SameSite=Lax; without the __Host- prefix and Secure only on http://localhost). The row is keyed by the cookie's SHA-256, never the cookie itself. No token reaches the page's scripts; the provider's refresh token stays on the server, encrypted with ENCRYPTION_SECRET.
  • Roles from the provider. The role comes from a claim in the ID token (roles by default), mapped by OIDC_ROLE_MAP, at every sign-in and every re-check. A person with no mapped value gets no session at all, not read-only access.
  • CSRF guard. Requests that carry the session cookie must come from the console's own origin (exact Origin, Sec-Fetch-Site same-origin or none), and every write carries an X-CSRF-Token header that the page keeps in memory. Bearer credentials (API keys, CLI tokens) are not subject to it.
  • Re-check with the provider. When a person's last check is older than OIDC_REVALIDATE_MINUTES (default 60), their next request first exchanges the stored refresh token with the provider. A refusal, or a new ID token with no mapped role, ends their console sessions and CLI sign-ins at once. While the provider cannot be reached, one more interval is grace; after that requests answer 503, never a sign-out. A person with no refresh token is checked only at sign-in, and their session lasts at most OIDC_SESSION_MAX_HOURS. Details: When access ends.
  • Sign out everywhere. An administrator, in a signed-in session, can end another person's console sessions and CLI sign-ins from Settings → Users. It does not disable the person (that is done at the provider) and does not revoke their API keys.
  • Break-glass principal. Someone with root on the server can print a one-time link (10 minutes, works once) to a break-glass session, for when the provider is down or every administrator is locked out. It acts as the user break-glass, is never checked with the provider, ends after 60 minutes at most, and has exactly an admin-scope API key's permissions. It is not a signed-in user session, so every action in the list below is refused to it. Its use is written to the backend's log. Details: Break-glass.

API keys and CLI tokens​

Two bearer credentials stand in for a signed-in user. Neither has MFA or a session step-up, so both are kept away from user and key management.

  • API keys (pa_..., created under Settings → API keys) carry a scope instead of a role: read (every permission ending in :read), read-write (the operator permissions) or admin (the admin permissions without settings:users:manage). An admin key can run a shell command on any agent, so treat it like an admin password. API keys are not available on Vercel. See Programmatic access.
  • CLI tokens are issued to the achilles CLI after a browser sign-in. The access token lasts one hour and is bound to the deployment: its audience is the server's AGENT_SERVER_URL, so a token from another install is refused even when both share a CLI_AUTH_SECRET. Changing AGENT_SERVER_URL invalidates outstanding access tokens; the CLI gets a new one on its next refresh. A token stops working when its user is removed or their role changes. In OIDC mode its requests are re-checked with the provider like a console session's.

Actions that need a browser session​

These are refused (403, This action requires a signed-in user session) for API keys, CLI tokens and break-glass sessions, whatever their scope or role:

  • everything under /api/api-keys (list, create, revoke);
  • every change under /api/users (invite, change role, remove). An admin's CLI session can still list users and invitations;
  • approving a CLI sign-in code (POST /api/cli/auth/verify);
  • changing the console identity (PUT and DELETE /api/settings/identity).

So a leaked key or token can't create more keys or admins, and revoking it contains the incident.

Tier 2: Agent API Keys​

Agents authenticate with unique keys issued during enrollment.

  • Separate from Clerk and from the identity provider — agents do not need web credentials, and keep working while the provider is down
  • Keys bound to specific agent ID
  • The server stores only a bcrypt hash of each key
  • Zero-downtime rotation — new key delivered via heartbeat; the rotation resolves on which key the agent presents, not on a timer, so an agent that was offline through the grace period is never locked out
  • On the endpoint, the key is stored encrypted at rest (AES-256-GCM with machine-bound key derivation)
  • Failed authentications with an unknown agent ID are limited to 60 per minute per IP address

Tier 3: Enrollment Tokens​

One-time or limited-use tokens for agent registration.

  • Configurable TTL and maximum usage count
  • Revocable through admin interface
  • Timing-oracle resistant (constant-time bcrypt with dummy hash on miss)

Tier 4: Integration Credentials​

Third-party service credentials stored encrypted:

  • Microsoft Defender: tenant/client/secret
  • CrowdStrike Falcon: client ID/secret
  • SentinelOne: API token
  • Sophos Central: client ID/secret
  • Slack webhook URL
  • SMTP credentials
  • All AES-256-GCM encrypted at rest in ~/.projectachilles/integrations.json