add auth profiles to wrangler #13975
Closed
emily-shen wants to merge 16 commits into
Closed
Conversation
🦋 Changeset detectedLatest commit: 4ed9988 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
2c9d214 to
1363e78
Compare
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
Contributor
|
✅ All changesets look good |
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Contributor
|
@emily-shen - looks like the Ci is not happy and there are some suggestions from Devin. |
9800b0c to
d13436f
Compare
Allow users to be logged into multiple Cloudflare accounts simultaneously via named profiles stored as separate TOML files. - Add `wrangler profile list|use|delete` subcommands - Add `--profile` global flag and WRANGLER_PROFILE env var - Support `wrangler login --profile <name>` to store credentials - Namespace account cache per profile to prevent cross-contamination - Display active profile in `wrangler whoami` output Profile resolution priority: --profile flag > WRANGLER_PROFILE env > profiles.toml > "default" Profiles stored under ~/.wrangler/config/profiles/<name>.toml. Default profile path unchanged for full backward compatibility. Refs: #8956, #11513
Unify login handler to a single code path so the profile success message and metrics event fire regardless of --scopes usage. Fix profileExists, deleteProfile, and listProfiles to use environment-aware paths via getAuthConfigFilePath, so profiles created in staging are correctly found, listed, and deleted.
Validate WRANGLER_PROFILE and profiles.toml active_profile with validateProfileName() to prevent invalid profile names from being used in auth config file path construction. Also reinitialise auth tokens in clearProfileOverride() to keep cached credentials in sync when the active profile changes.
deleteProfile() previously used getActiveProfile() to check whether the deleted profile was active, but getActiveProfile() respects --profile and WRANGLER_PROFILE overrides. This meant profiles.toml could be left pointing at a deleted profile when a different override was active. Extract getActiveProfileFromConfig() to read profiles.toml directly, ignoring runtime overrides, and use it in deleteProfile().
- Add profile field to whoami --json test expectation - Update inline snapshots for experimental-commands-api and functions-build
- Add WRANGLER_PROFILE to VariableNames type in workers-utils - Fix "open-beta" -> "open beta" status enum in profile commands - Use expect from test context in profile.test.ts (lint rule)
28a3ff7 to
206d263
Compare
206d263 to
d856697
Compare
emily-shen
commented
May 21, 2026
| import type { ExpectStatic } from "vitest"; | ||
|
|
||
| describe("containers registries --help", () => { | ||
| runInTempDir(); |
Contributor
Author
There was a problem hiding this comment.
have had to do this to a bunch of test files to make sure that running tests locally while you have a profile active doesn't contaminate the snapshots
d856697 to
ae58fb1
Compare
3fbaf9d to
bef712f
Compare
bef712f to
d674d6a
Compare
d674d6a to
a699560
Compare
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
c774e29 to
4ed9988
Compare
Contributor
Author
|
see #14200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #11780
'Profiles' are essentially just Oauth tokens that you can switch between without re-authing. The main change compared to the earlier PR is that you can now bind a profile to a particular directory.
New commands/flags
npx wrangler login/out --profile --dir- binds and unbinds a profile to a directory (defaults to cwd if --dir is not passed in). Login offers to create the profile if it does not exist, and logout offers to delete if nothing else is using the profile.npx wrangler profiles create- creates without setting the profilenpx wrangler profiles delete- revoke token and unbind all directoriesnpx wrangler profiles listAlso adds the env var WRANGLER_PROFILE to override any directory bindings as a one off.
TODO in follow up:
A picture of a cute animal (not mandatory, but encouraged)