Add per-project authentication support with wrangler login --project#12507
Add per-project authentication support with wrangler login --project#12507roerohan wants to merge 8 commits intocloudflare:mainfrom
wrangler login --project#12507Conversation
🦋 Changeset detectedLatest commit: ed84cc0 The changes in this PR will be included in the next version bump. 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 |
wrangler login --project
create-cloudflare
@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: |
…YPE=global forces global token loading
7c2abb4 to
834b53e
Compare
|
Thanks for putting this together @roerohan - I need to dig around a bit more but I think that at least some of this is not really necessary, since XDG paths already provide the ability to change where Wrangler will look for the global config. I think that could be leveraged instead of a new |
Thanks @petebacondarwin ! Happy to make changes as needed, feel free to edit my branch if you want to 😄 |
This PR adds per-project authentication support to Wrangler, allowing users to maintain separate authentication credentials for different projects. Instead of being limited to a single global authentication, developers can now log in with different Cloudflare accounts in different project directories.
Key Changes
New Command Flags:
wrangler login --project (aliases: --directory, --local)- Store OAuth tokens in local.wrangler/config/default.tomlwrangler logout --project- Remove local authenticationNew Environment Variables:
WRANGLER_HOME- Customize the global config directory locationWRANGLER_AUTH_TYPE=global- Force all commands to use global auth instead of local (useful when you have local auth but temporarily need global)Authentication Priority:
CLOUDFLARE_API_TOKEN,CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL)WRANGLER_AUTH_TYPE=global- Forces global auth.wrangler/config/default.tomlin project)~/.wrangler/config/default.toml)Enhanced User Feedback:
wrangler whoaminow displays the authentication source (local or global) with the file pathwrangler login --projectshows a confirmation message with the auth file locationExample Usage
Login globally (default behavior)
In project Agents, login with a different account
All commands in this project now use local auth automatically
Force using global auth temporarily
wrangler login --helpshows--projectflag with all aliaseswrangler logout --helpshows--projectflagwrangler whoamidisplays correct auth source (local vs global)WRANGLER_AUTH_TYPE=globalforces global auth when local auth existsA picture of a cute animal (not mandatory, but encouraged)
