You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7bb6eae
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Include preview token in Access probes and login (#15159)
Co-authored-by: Eric Falcao <efalcao@cloudflare.com>
Co-authored-by: Christopher Little-Savage <clittle-savage@cloudflare.com>
Fix `wrangler dev` remote bindings for `workers.dev` subdomains protected by Access
6
+
7
+
Running `wrangler dev` with remote bindings on an unpublished worker protected by Access (e.g. using a wildcard on your workers.dev domain) previously failed with a redirect loop. Wrangler now correctly authenticates remote bindings with Access in this situation.
// Knowledge of the preview token allows you to route to the unpublished
189
+
// worker (which may have production bindings and production cache) so in some
190
+
// sense it's a secret.
191
+
//
192
+
// During the Access login flow, the preview token may be visible to other
193
+
// processes on the machine. It will also appear in browser history and may be
194
+
// sent to third parties like the identity provider. Are these leaks safe?
195
+
//
196
+
// I argue yes! The preview worker is protected by Access, or we wouldn't be
197
+
// trying to log into it. So the preview token is necessary but not sufficient
198
+
// to reach it.
199
+
constoutput=awaitspawnCloudflaredAccessLogin(
200
+
buildProbeUrl(domain,options.previewToken),
201
+
options.signal
202
+
);
157
203
if(output.error){
158
204
thrownewUserError(
159
205
"To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation",
@@ -186,11 +232,13 @@ export async function getAccessHeaders(
186
232
* surface an installation hint.
187
233
*/
188
234
functionspawnCloudflaredAccessLogin(
189
-
domain: string,
235
+
loginTarget: string,
190
236
signal?: AbortSignal
191
237
): Promise<{error?: Error;stdout: string}>{
192
238
returnnewPromise((resolve,reject)=>{
193
-
constchild=spawn("cloudflared",["access","login",domain],{ signal });
Copy file name to clipboardExpand all lines: packages/wrangler/e2e/README.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,13 @@ pnpm test:e2e:wrangler
66
66
> You can find your subdomain in the Cloudflare dashboard under **Workers & Pages**.
67
67
> It defaults to `devprod-testing7928.workers.dev` (the CI account).
68
68
69
+
The Cloudflare Access tests need a self-hosted Access application covering a
70
+
wildcard of Worker names on that subdomain (for example
71
+
`my-access-test-*.<your-subdomain>.workers.dev`) with an interactive-login
72
+
policy. Set `E2E_ACCESS_WORKER_PREFIX=my-access-test-` to run them; otherwise
73
+
they are skipped when `E2E_ACCOUNT_WORKERS_DEV_DOMAIN` is overridden. The CI
74
+
account uses `wrangler-wildcard-test-`.
75
+
69
76
### Focusing on a single e2e test file
70
77
71
78
If you want to run a subset of tests (e.g. just one) while retaining the turborepo cache for the builds of the dependencies, you can provide the list of test files via the `WRANGLER_E2E_TEST_FILE` environment variable.
0 commit comments