[wrangler] Add multi-account profile support #11780
Open
+1,551
−51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds multi-account profile support to Wrangler, inspired by AWS CLI's profile system.
Summary
This PR introduces a profile system that allows users to store and switch between multiple Cloudflare user identities (OAuth tokens or API tokens) without re-authenticating.
Why
The Problem: Wrangler currently supports only a single authenticated user at a time. Developers who work across multiple Cloudflare accounts (personal projects, work, client accounts, staging vs production) must repeatedly run
wrangler loginto switch between them, losing their previous session each time.Use Cases:
Pain Points Addressed:
Workflow Unlocks:
.wrangler/profile) and forget about it--profileorWRANGLER_PROFILENew Commands
wrangler profile list- List all configured profiles with statuswrangler profile current- Show the currently active profile and how it was resolvedwrangler profile use <name>- Set the active profile (project-level by default,--globalfor global)wrangler profile delete <name>- Delete a profileNew Flags
wrangler login --profile <name>- Save credentials to a specific profilewrangler auth token --profile <name>- Get token from a specific profileProfile Resolution Precedence
--profileCLI flag (highest)WRANGLER_PROFILEenvironment variable.wrangler/profile(project-level)~/.wrangler/current-profile(global)defaultprofile (lowest)File Locations
~/.wrangler/credentials- All profiles (TOML format, 600 permissions)~/.wrangler/current-profile- Global active profile.wrangler/profile- Project-level active profileMigration
Existing OAuth tokens from
~/.wrangler/config/default.tomlare automatically migrated to thedefaultprofile on first use.