Skip to content

fix(studio): fetch identity services with redirect: 'manual' - #110

Open
rubenkalath wants to merge 1 commit into
flowtricks:mainfrom
rubenkalath:fix/studio-auth-redirect-manual
Open

rubenkalath wants to merge 1 commit into
flowtricks:mainfrom
rubenkalath:fix/studio-auth-redirect-manual

Conversation

@rubenkalath

Copy link
Copy Markdown

Problem

With AUTH_PROVIDER=oidc, and by the same code path google, pressing the sign-in button logs Studio auth provider failed { provider: 'oidc', step: 'begin' } and the person stays on the sign-in page.

studio/src/features/auth/providers/boundedFetch.ts calls the fetcher with redirect: 'error'. The Workers runtime refuses that value before anything is sent:

TypeError: Invalid redirect value, must be one of "follow" or "manual" ("error" won't be implemented since it does not make sense at the edge; use "manual" and check the response status code).

fetchJson catches the error and returns { kind: 'network' }. As a result, OIDC discovery, the JWKS fetch and the token exchange all fail. These are oidcFlow.ts and jwks.ts, used by both oidc.ts and google.ts. Unit tests pass because they run under Node, whose fetch accepts 'error'.

Reproduced under workerd 2026-10-12 (Miniflare 5.20261012.1-beta, the version Studio pins), with compatibility date 2026-10-16 and nodejs_compat.

Fix

  • boundedFetch.ts: use redirect: 'manual' instead of 'error'. A 3xx answer is not ok, so fetchJson still refuses it ({ kind: 'status', status }) and never follows it. That keeps the point of the old setting: a redirect cannot carry a client secret elsewhere.
  • studio/test/boundedFetchRedirect.test.ts: checks the fetcher is asked for manual, and that a 302 is a status failure.

Checks

  • tsc --noEmit, ESLint and Prettier on the changed files.
  • tsx --test test/boundedFetchRedirect.test.ts: 2 pass.
  • End to end: OIDC sign-in completes through Studio's Worker under workerd.

redirect: 'error' also appears in publishing/publishStatusRemote.ts, publishing/deployment.ts and preview/renderPushServer.ts. Any of those that runs in the Worker rather than in the container (Node) would fail the same way. Not changed here.

The Workers runtime refuses redirect: 'error' ("won't be implemented"),
so OIDC discovery, JWKS and token fetches all failed as network errors and
Google and OIDC sign-in could not complete. A 3xx answer is not ok, so it
is still refused rather than followed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant