Repository navigation
Feature request: wrangler auth use <name> to switch the globally active auth profile
#17144
anishmenon
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
The new auth profiles (RFC #14161, shipped July 2026) are great for pinning a project directory to an account. What is still missing is the thing every other cloud CLI has: a global "which account am I using right now" switch, like
gh auth switch,gcloud config set accountorkubectl config use-context.Today, to work as a different account you must either:
wrangler auth activate <name>in every directory you touch (and remember to clean the bindings up), or--profile <name>, orCLOUDFLARE_AUTH_PROFILEin each shell.None of those fits the common case of "I am doing client-B work for the afternoon, in several directories and ad-hoc
wranglercalls, then switching back". Re-runningwrangler loginto swap the default profile throws away the previous session, which is exactly what the RFC set out to avoid.The RFC itself notes that directory scoping is novel and that AWS, gcloud and kubectl use one global context. I do not think the two are in tension: directory bindings are the right tool for agents and pinned repos, and a global switch is the right tool for a human moving between accounts.
Proposal
Add
wrangler auth use <name>(possibly aliased aswrangler auth switch) that sets a user-level global active profile, consulted after directory bindings and before the default:wrangler auth use workswitches globally.wrangler auth use defaultgoes back to the default profile. With no argument, an interactive picker.auth usewarns when a binding or the env var still takes precedence in the current directory.wrangler auth listshows which profile is active here, which is the global switch, and where the current selection came from.wrangler auth deleteclears the switch if you delete the active profile;wrangler auth deactivatefalls back to the global profile before the default.active_profilein the existingpreferences.json. A stale value (profile since deleted) is ignored rather than breaking every command.Example:
Implementation
I have a working, tested implementation in #17143 (auto-closed because I am not a vouched collaborator). It adds
ProfileStore.globalandresolveWithSource()to@cloudflare/workers-authwith the optional storage defaulting to the previous behaviour, and theauth usecommand plusauth list/auth delete/auth deactivateupdates inwrangler. Tests cover both thecfandwranglerstores and the command behaviour. Happy to adjust naming (usevsswitchvsselect) or precedence if the team prefers something different, or to hand the branch over.All reactions