ci: harden the post-deploy smoke on access-gated and public hosts - #269
Merged
Conversation
FrkAk
force-pushed
the
ci/access-smoke-token
branch
from
July 28, 2026 15:08
2793014 to
6a5d892
Compare
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
Task Reference: [PYZ-372]
The post-deploy smoke added in #261 can never pass on the dev head:
dev.app.piyaz.aisits behind Cloudflare Access, so the edge answers every unauthenticated probe and the Worker is never reached. The first Deploy Dev run after that merge failed on the challenge page while the Worker itself was healthy. This authenticates through Access with a service token, confines the gate-detection skip to callers that declare themselves gated, and widens what the probe actually proves.Access handling
deploy-workeraction gainsaccess_client_id/access_client_secretinputs; the probe sendsCF-Access-Client-Id/CF-Access-Client-Secretwhen set. The token's Access policy must use the Service Auth decision.access_gatedinput (defaultfalse) controls whether an unreachable host may downgrade to a warning. Onlydeploy-dev.ymlsets it.deploy.ymlis public and always fails hard, so a Cloudflare bot or WAF challenge onapp.piyaz.aican never be read as a passing smoke.cf-mitigatedis excluded from the gate markers for the same reason: it marks a WAF challenge, not Access.Probe coverage
<base>/api/auth, not just for the presence of the key. A wrongBETTER_AUTH_URLbinding serves well-formed metadata and breaks OAuth for every MCP client.POST /api/mcpmust return 401, proving the MCP module loaded and the bearer path runs on the live deployment.Handling of the service token
--max-redirs 0pins the no-replay invariant: curl strips credentials across a cross-host redirect but replays arbitrary-Hheaders, so a later-Lwould hand the token to the redirect target.CF_AuthorizationJWT after a successful handshake and is removed on every exit path.bun installand the deploy script.Until the secrets are minted the skip path keeps Deploy Dev green. To restore the hard gate: create an Access service token, attach it to the dev Access application with a Service Auth policy, and set
CF_ACCESS_SMOKE_CLIENT_ID/CF_ACCESS_SMOKE_CLIENT_SECRET.Type of change
Testing
bun run devbun run lint)bun run typecheck)bun run build:cf && bun run smoke:cf) — not applicable, no runtime code touchedBoth files parse as valid YAML and the step passes
bash -n. The step script was run against a stubbedcurlacross 13 scenarios covering both callers: public happy path, WAF challenge on the public host, Access markers on the public host, 5xx, wrong issuer, MCP non-401, 404 retry exhaustion, gated with no token, gated with a valid token, gated with a rejected token, gated with a real 5xx, and each half-configured token pair. The public host fails hard in every non-200 case; the gated host warns only when no token is configured. The issuer assertion was pinned against the live public metadata document, which returnshttps://app.piyaz.ai/api/auth.Notes for reviewer
Run 30370207503 shows the failure shape this fixes:
wrangler deploysucceeded and the version went live; the smoke then read the edge's challenge interstitial as a Worker error.The
/api/mcpprobe mirrors the request shape already asserted byscripts/smoke-workers.ts, which expects 401 for the same headers and body on local workerd.Follow-up not in this PR: no probe exercises the Neon HTTP driver on the deployed head, so the Workers DB path is still verified by nothing in CI.
Docs impact
Compliance impact