Context
The Gastown API (worker) currently sits behind Cloudflare Access. In production, containers need to call back to the worker at GASTOWN_API_URL, but CF Access blocks those requests because the container doesn't have CF Access credentials.
The naive fix — passing CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET into containers — is a serious security risk. Any user's agent code running in the container could exfiltrate those credentials, which grant broad access to the CF Access-protected application.
Proposed solution
- Remove Cloudflare Access from the Gastown worker route
- Add direct JWT validation inside the Gastown API using the
NEXTAUTH_SECRET (or equivalent signing key), similar to how the main Kilo API validates requests
- The Gastown worker already mints its own JWTs (
GASTOWN_JWT_SECRET) for agent session tokens — those continue to work for container→worker auth. The additional validation is for requests coming from the Next.js app (dashboard, tRPC proxy)
- Add the
NEXTAUTH_SECRET as a secret binding in the Gastown worker's wrangler config (via wrangler secret put)
- The Gastown API will then behave like a normal authenticated API — no CF Access edge layer needed
Acceptance criteria
Parent issue
Part of #204 (Phase 3)
Context
The Gastown API (worker) currently sits behind Cloudflare Access. In production, containers need to call back to the worker at
GASTOWN_API_URL, but CF Access blocks those requests because the container doesn't have CF Access credentials.The naive fix — passing
CF_ACCESS_CLIENT_IDandCF_ACCESS_CLIENT_SECRETinto containers — is a serious security risk. Any user's agent code running in the container could exfiltrate those credentials, which grant broad access to the CF Access-protected application.Proposed solution
NEXTAUTH_SECRET(or equivalent signing key), similar to how the main Kilo API validates requestsGASTOWN_JWT_SECRET) for agent session tokens — those continue to work for container→worker auth. The additional validation is for requests coming from the Next.js app (dashboard, tRPC proxy)NEXTAUTH_SECRETas a secret binding in the Gastown worker's wrangler config (viawrangler secret put)Acceptance criteria
GASTOWN_SESSION_TOKEN(existing JWT)Parent issue
Part of #204 (Phase 3)