Skip to main content

Integration verification with curl

Run these six curl checks against your local or staging server before publishing auth.md. First, mint a 5-minute test token using POST /api/v1/token/exchange and your aon_live_... API Key:

1. Unknown email returns 403 ACCOUNT_REQUIRED

Before your email exists in your app’s database, call a protected endpoint:
Expected: HTTP 403 with {"code": "ACCOUNT_REQUIRED", ...}. If you receive 401, fix your status mapping so agents follow your 403 account-setup instructions instead of re-minting tokens.

2. Signup creates once and is idempotent on retry

If you implemented POST /api/signup with createAgentAccount:
Check your database table to confirm only one user row exists for that email.

3. Tampered or wrong-Domain tokens return 401 without touching your DB

Corrupt the last character of the JWT signature and call both routes:
Expected: HTTP 401 with {"code": "INVALID_SIGNATURE", ...} on both routes, with zero database queries executed. Also test:
  • No Authorization header: Expect 401 MALFORMED_TOKEN.
  • Wrong Domain: Mint a token with {"audience": "other-domain.com"} and send it to your endpoint. Expect 401 AUDIENCE_MISMATCH.

4. Expired tokens return 401 EXPIRED

Wait 5 minutes (plus 5 seconds for clock tolerance) and replay the original $TOKEN:
Expected: HTTP 401 with {"code": "EXPIRED", ...}.

5. Database exceptions return 500 RESOLVER_ERROR without leaking secrets

Temporarily throw new Error("db-secret-test-string") inside resolveAccount and call your endpoint. Expected: HTTP 500 with {"code": "RESOLVER_ERROR", ...}, and confirm "db-secret-test-string" never appears in the HTTP response body. Remove the test throw afterward.

6. auth.md matches your live responses

Fetch both discovery paths and verify:
  • Both return 200 OK over HTTPS with no login redirect.
  • The hostname under ## Audience matches the audience option in your backend code.
  • The 403 row in ## When a request is rejected matches your live behavior (human connect URL or POST /api/signup).

JWKS caching and production runtime

This section documents how @agentonboard/sdk (agentonboard/js-sdk) and agentonboard-sdk (agentonboard/agentonboard-python-sdk) fetch, cache, and rotate public JWKS keys in production.

How key resolution works per request

On each request, the SDK decodes the JWT header to read kid, resolves the matching RSA public key, verifies the signature and claims, and runs your resolveAccount callback. The SDK uses your runtime’s global fetch (TypeScript) or httpx (Python) with zero filesystem or socket dependencies.
Local verification refreshes JWKS once per hourVerification does not call AgentOnboard per request, and a cold process fetches /.well-known/jwks.json on its first verification. Long-running processes refresh the cached key set once per hour (CACHE_MAX_AGE_MS = 3_600_000).

Caching and last-known-good fallback

Every fetched JWKS response is shape-checked before caching:
  • It must contain a keys array of valid RSA public keys (2048 bits minimum) with unique kid strings.
  • Malformed JSON, non-RSA keys, or duplicate kid values are treated as a failed fetch.
When a JWKS fetch fails or times out, a warm process falls back to the last validated key set held in memory.
Cold starts have no fallback key setKEY_SOURCE_UNAVAILABLE fires only when a JWKS fetch fails and the process has no cached key set in memory (such as the first request after a deploy during a JWKS outage). Warm instances continue verifying with cached keys.
Cache bounds and timers:
  • Cache TTL: 1 hour (3,600,000 ms).
  • Unknown kid refetch cooldown: 30 seconds in TypeScript (60 seconds in Python). Prevents a flood of forged tokens with fake kid values from triggering a flood of JWKS requests.
  • Maximum cached key sources: 8 distinct issuer URLs per process (LRU-evicted).

Key rotation

When AgentOnboard rotates Signing Keys:
  1. New tokens arrive with a new kid in the header.
  2. Your server sees the unknown kid and refetches /.well-known/jwks.json once the 30-second cooldown has elapsed.
  3. The new public key loads into memory and verification continues without dropping requests.
Once an old kid is removed from /.well-known/jwks.json, tokens signed by that retired key fail with UNKNOWN_KEY.

Operational edge cases

When the 1-hour cache expires and /.well-known/jwks.json is unreachable or slow, the request triggering the refresh waits up to the 5-second fetch timeout before falling back to the last-known-good key set.If your serverless function or API gateway enforces a strict 3-second request timeout, that 5-second wait will time out the request. To avoid this:
  1. Set route timeouts on agent-protected endpoints above 5 seconds, or
  2. Warm the verifier at process startup, or
  3. Pass a custom fetchJwks callback with a shorter AbortSignal.timeout(1500).
  • Alert on KEY_SOURCE_UNAVAILABLE: a cold-start instance could not reach /.well-known/jwks.json.
  • Alert on spikes in UNKNOWN_KEY: indicates a key rotation, a staging environment missing AON_ISSUER, or forged tokens.
If your custom fetchJwks callback throws, the SDK discards the raw error message and returns a generic KEY_SOURCE_UNAVAILABLE description so internal proxy URLs or credentials never leak into 401 bodies. Log errors inside fetchJwks before rethrowing.

Fixed cryptographic constants

These parameters are pinned in the SDK:

Production deployment checklist

  • audience is hardcoded in your server source and matches ## Audience in auth.md.
  • AON_ISSUER (or issuer) is set on any non-production environment verifying against a non-production issuer.
  • Route timeouts on protected endpoints allow at least 5 seconds for cold-start or hourly JWKS fetches.
  • ACCOUNT_REQUIRED returns HTTP 403 (not 401).
  • Regular routes use verifyAgentAccount (requireAgentAccount), and createAgentAccount is only used on an explicit POST /api/signup route if you opt into agent signup.
  • Application logs record code and jti, never raw JWTs or Authorization headers.
  • Monitoring alerts on KEY_SOURCE_UNAVAILABLE and spikes in UNKNOWN_KEY.
  • Both https://<your-domain>/auth.md and https://<your-domain>/.well-known/auth.md return 200 OK over HTTPS and match your live error codes.