(janitor/dedupe): consolidate Cloudflare Access JWT validation onto worker-utils - #5760
Merged
pandemicsyn merged 1 commit intoAug 31, 2026
Merged
Conversation
…orker-utils wasteland and gastown each carried a byte-identical copy of the Cloudflare Access JWT validation middleware (~230 lines): the same validateCfAccessRequest entry point, the hand-rolled RS256 verification against the /cdn-cgi/access/certs JWKS endpoint, and the full set of Access* zod schemas. A fix to issuer/audience/expiry handling or a Cloudflare Access schema change would have to be applied to both copies by hand. Both services already depend on @kilocode/worker-utils and run in the Cloudflare Workers runtime, so the dependency direction is clean: - packages/worker-utils/cf-access: new single owner for the validation core (validateCfAccessRequest plus the Access* schemas and helpers). - wasteland/gastown: delete the duplicated middleware files and import validateCfAccessRequest from @kilocode/worker-utils/cf-access. The dead withCloudflareAccess Hono adapter in each copy was dropped; the only actual call sites used validateCfAccessRequest directly. The Workers-only `cf` edge-cache option on the certs fetch is typed locally to avoid pulling @cloudflare/workers-types into worker-utils. No behavior change: the two copies were byte-identical.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by grok-4.6 · Input: 82.3K · Output: 8.2K · Cached: 285.1K Review guidance: REVIEW.md from base branch |
pandemicsyn
approved these changes
Aug 31, 2026
pandemicsyn
deleted the
session/agent_243b759d-5fc8-4237-81fa-e931230720bc
branch
August 31, 2026 17:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wastelandandgastowneach carried a byte-identical copy of the Cloudflare Access JWT validation middleware (~230 lines each): the samevalidateCfAccessRequestentry point, the hand-rolled RS256 verification against the/cdn-cgi/access/certsJWKS endpoint, and the full set ofAccess*zod schemas.A fix to issuer/audience/expiry handling, or a Cloudflare Access schema change, would have to be applied to both copies by hand — classic drift risk in security-critical code.
Change
Both services already depend on
@kilocode/worker-utilsand run in the Cloudflare Workers runtime, so the dependency direction is clean:packages/worker-utils/cf-access— new single owner for the validation core (validateCfAccessRequestplus theAccess*schemas and helpers).wasteland/gastown— delete the duplicated middleware files and importvalidateCfAccessRequestfrom@kilocode/worker-utils/cf-access.The dead
withCloudflareAccessHono adapter in each copy was dropped; the only actual call sites usedvalidateCfAccessRequestdirectly. The Workers-onlycfedge-cache option on the certs fetch is typed locally to avoid pulling@cloudflare/workers-typesintoworker-utils.Verification
pnpm --filter @kilocode/worker-utils run typecheck— passpnpm --filter cloudflare-wasteland run typecheck— passpnpm --filter cloudflare-gastown run typecheck— passpnpm --filter @kilocode/worker-utils run lint— passpnpm --filter cloudflare-wasteland run lint/cloudflare-gastown— passpnpm --filter @kilocode/worker-utils run test— 357 passedoxfmt --check— passNo behavior change: the two copies were byte-identical.