[wrangler] Fix Access Service Token authentication for service-auth-only apps - #14008
Conversation
…nly apps When using remote bindings against a Worker behind a Cloudflare Access application configured to only allow Service Auth tokens (no interactive user authentication), Wrangler previously ignored the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET env vars and the request would fail with a 403. The detection method in domainUsesAccess() looks for a 302 redirect to cloudflareaccess.com. A service-auth-only Access app has no interactive login path, so it responds with a hard 403 instead of redirecting. Wrangler concluded the domain was not behind Access and skipped attaching the service token headers entirely. The env-var check now runs before the Access detection step, so the configured service token credentials are always used when present.
🦋 Changeset detectedLatest commit: 00a4325 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
I've now thoroughly reviewed the changes. Let me analyze:
Everything looks correct. The fix is minimal, well-tested, and well-documented. LGTM |
|
✅ All changesets look good |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
When using remote bindings against a Worker behind a Cloudflare Access application configured to only allow Service Auth tokens (no interactive user authentication), Wrangler previously ignored the
CLOUDFLARE_ACCESS_CLIENT_IDandCLOUDFLARE_ACCESS_CLIENT_SECRETenv vars and the request would fail with a 403. This came up via reports from users using Wrangler for OpenNext pre-render uploads against a Worker behind Access, where the documented workaround of setting those env vars wasn't taking effect.The detection method in
domainUsesAccess()looks for a 302 redirect tocloudflareaccess.com. A service-auth-only Access app has no interactive login path, so it responds with a hard 403 instead of redirecting. Wrangler concluded the domain was not behind Access and skipped attaching the service token headers entirely.The env-var check now runs before the Access detection step, so the configured service token credentials are always used when present. A code comment has been added explaining why the order matters to prevent regression.
CLOUDFLARE_ACCESS_CLIENT_ID/CLOUDFLARE_ACCESS_CLIENT_SECRETenv vars for an additional Access configuration.A picture of a cute animal (not mandatory, but encouraged)