Skip to content

[wrangler] Add Access Service Token support for CI/non-interactive environment#13031

Merged
WalshyDev merged 5 commits intomainfrom
walshy/access-service-token-support
Mar 24, 2026
Merged

[wrangler] Add Access Service Token support for CI/non-interactive environment#13031
WalshyDev merged 5 commits intomainfrom
walshy/access-service-token-support

Conversation

@WalshyDev
Copy link
Copy Markdown
Member

@WalshyDev WalshyDev commented Mar 23, 2026

Fixes #11881.

When running wrangler dev with remote bindings (or vitest-pool-workers with remote bindings) behind a Cloudflare Access-protected domain, Wrangler spawns cloudflared access login which 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 ID
  • CLOUDFLARE_ACCESS_CLIENT_SECRET -- the Access Service Token Client Secret

When both are set, Wrangler authenticates by sending CF-Access-Client-Id and CF-Access-Client-Secret headers to the Access-protected domain -- completely bypassing the interactive cloudflared flow.

Additionally, when running in a non-interactive environment (no TTY or CI detected) without these credentials, Wrangler now throws a clear, actionable UserError instead of hanging on cloudflared 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

export CLOUDFLARE_ACCESS_CLIENT_ID="<your-client-id>.access"
export CLOUDFLARE_ACCESS_CLIENT_SECRET="<your-client-secret>"
wrangler dev --remote


Open with Devin

@WalshyDev WalshyDev requested a review from a team as a code owner March 23, 2026 23:46
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 23, 2026

🦋 Changeset detected

Latest 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

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Mar 23, 2026
@WalshyDev WalshyDev changed the title [wrangler] Add Access Service Token support for CI/non-interactive en… [wrangler] Add Access Service Token support for CI/non-interactive environment Mar 23, 2026
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 23, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 23, 2026

APIError: Not Found: Not found

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 23, 2026

@WalshyDev Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 23, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13031

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13031

miniflare

npm i https://pkg.pr.new/miniflare@13031

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13031

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13031

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13031

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13031

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13031

wrangler

npm i https://pkg.pr.new/wrangler@13031

commit: 55580e4

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

✅ 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
@WalshyDev WalshyDev force-pushed the walshy/access-service-token-support branch from 0304247 to 3c71642 Compare March 24, 2026 12:10
devin-ai-integration[bot]

This comment was marked as resolved.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 24, 2026
@WalshyDev WalshyDev merged commit eeaa473 into main Mar 24, 2026
49 of 50 checks passed
@WalshyDev WalshyDev deleted the walshy/access-service-token-support branch March 24, 2026 13:08
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Not possible to cloudflared access login on CI

3 participants