[wrangler] Add Access Service Token support for CI/non-interactive environment#13031
Merged
[wrangler] Add Access Service Token support for CI/non-interactive environment#13031
Conversation
🦋 Changeset detectedLatest commit: 55580e4 The changes in this PR will be included in the next version bump. 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 |
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
Contributor
|
APIError: Not Found: Not found |
Contributor
|
@WalshyDev Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
Contributor
|
✅ All changesets look good |
…vironments Support authenticating with Cloudflare Access-protected domains via CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET env vars. This enables wrangler dev with remote bindings in CI where cloudflared access login is not possible. Refactored getAccessToken -> getAccessHeaders to return a headers dict directly. For service tokens, the CF-Access-Client-Id and CF-Access-Client-Secret headers are passed through on every request instead of exchanging them for a JWT. For cloudflared tokens, a Cookie: CF_Authorization header is returned. When running in a non-interactive environment without these credentials, throw a clear, actionable error instead of hanging on cloudflared. Fixes #11881
0304247 to
3c71642
Compare
dario-piotrowicz
approved these changes
Mar 24, 2026
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.
Fixes #11881.
When running
wrangler devwith remote bindings (orvitest-pool-workerswith remote bindings) behind a Cloudflare Access-protected domain, Wrangler spawnscloudflared access loginwhich opens a browser for interactive authentication. This is impossible in CI/CD environments.This PR adds support for Cloudflare Access Service Token authentication via two new environment variables:
CLOUDFLARE_ACCESS_CLIENT_ID-- the Access Service Token Client IDCLOUDFLARE_ACCESS_CLIENT_SECRET-- the Access Service Token Client SecretWhen both are set, Wrangler authenticates by sending
CF-Access-Client-IdandCF-Access-Client-Secretheaders to the Access-protected domain -- completely bypassing the interactivecloudflaredflow.Additionally, when running in a non-interactive environment (no TTY or CI detected) without these credentials, Wrangler now throws a clear, actionable
UserErrorinstead of hanging oncloudflared access login:The domain "example.workers.dev" is behind Cloudflare Access, but no Access Service Token
credentials were found and the current environment is non-interactive.
Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables
to authenticate with an Access Service Token.
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/
Usage
CLOUDFLARE_ACCESS_CLIENT_IDandCLOUDFLARE_ACCESS_CLIENT_SECRETsystem environment variables cloudflare-docs#29256