Patch Changes
-
#14121
7539a9bThanks @petebacondarwin! - Extract the OAuth 2.0 + PKCE flow into a new@cloudflare/workers-authpackage.The OAuth login / logout / refresh logic, the auth-config TOML file IO, the OAuth token exchange + local callback server, and the Cloudflare Access detection helpers that previously lived in
packages/wrangler/src/user/have moved to the new internal-only@cloudflare/workers-authpackage. Wrangler now wires the OAuth flow up via a small glue module that injects its logger, browser opener, interactivity detector, and config cache via a dependency- injection context.What stays in wrangler:
- The yargs
login/logout/whoami/auth tokencommands - Environment-based credential resolution (
CLOUDFLARE_API_TOKEN,CLOUDFLARE_API_KEY/CLOUDFLARE_EMAIL, etc.) - Cloudflare account selection (
requireAuth,getOrSelectAccountId) - The OAuth scope catalog (passed into the OAuth flow as a generic
string[]) whoami/ account fetching
No behavior change for end users. The on-disk TOML format and location remain identical, and all telemetry message labels are preserved verbatim.
@cloudflare/workers-authis published withprerelease: trueand is not intended for external use — its APIs may change without notice. - The yargs
-
#14170
ea12b58Thanks @petebacondarwin! - Tighten on-disk permissions of the OAuth credentials file to0600The user auth config file written by
wrangler login(typically~/.config/.wrangler/config/default.tomlon Linux/macOS, or<environment>.tomlfor non-production Cloudflare API environments) is now written with mode0600and re-chmod-ed on every save. This prevents other local users on shared hosts from reading the stored OAuth tokens. Existing files with looser permissions written by older Wrangler versions are tightened the next time Wrangler refreshes the token or the user logs in again. The change is a no-op on Windows, which does not honour POSIX mode bits. -
#14022
acf7817Thanks @petebacondarwin! - Show the actual OAuth error instead of hanging whenwrangler loginis rejected by the OAuth provider (for example withinvalid_scope).Previously, if the OAuth callback returned with an
errorother thanaccess_denied, Wrangler would never respond to the browser. Becauseserver.close()'s callback only fires once all open connections have ended, the login command would hang until the 120 second OAuth timeout — at which point it would print a generic timeout message rather than the actual OAuth failure. The same gap existed for the case where the OAuth provider redirected back without an authorisation code, and for failures during the auth-code-to-access-token exchange.The OAuth provider's
error_description(RFC 6749 §4.1.2.1) is now also surfaced, so the message includes the specific reason for the failure rather than just the bareerrorcode. For example, a misconfigured staging scope now surfaces as:OAuth error: invalid_scope The OAuth 2.0 Client is not allowed to request scope 'browser:write'.instead of hanging silently.
-
Updated dependencies [
c6c61b5,b502d54,c4f45e8]:- @cloudflare/workers-utils@0.23.0