Skip to content

Add per-project authentication support with wrangler login --project#12507

Open
roerohan wants to merge 8 commits intocloudflare:mainfrom
roerohan:roerohan/wrangler-project-login
Open

Add per-project authentication support with wrangler login --project#12507
roerohan wants to merge 8 commits intocloudflare:mainfrom
roerohan:roerohan/wrangler-project-login

Conversation

@roerohan
Copy link

@roerohan roerohan commented Feb 10, 2026

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.toml
  • wrangler logout --project - Remove local authentication

New Environment Variables:

  • WRANGLER_HOME - Customize the global config directory location
  • WRANGLER_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:

  1. Environment variables (CLOUDFLARE_API_TOKEN, CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL)
  2. WRANGLER_AUTH_TYPE=global - Forces global auth
  3. Local project auth (.wrangler/config/default.toml in project)
  4. Global auth (~/.wrangler/config/default.toml)

Enhanced User Feedback:

  • wrangler whoami now displays the authentication source (local or global) with the file path
  • wrangler login --project shows a confirmation message with the auth file location

Example Usage

Login globally (default behavior)

wrangler login

In project Agents, login with a different account

cd ~/agents
wrangler login --project

All commands in this project now use local auth automatically

wrangler whoami  # Shows: "Auth source: local (.wrangler/config/default.toml)"
wrangler deploy  # Uses local auth

Force using global auth temporarily

WRANGLER_AUTH_TYPE=global wrangler whoami
# Logout from local auth
wrangler logout --project

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
      • Verified wrangler login --help shows --project flag with all aliases
      • Verified wrangler logout --help shows --project flag
      • Verified wrangler whoami displays correct auth source (local vs global)
      • Verified WRANGLER_AUTH_TYPE=global forces global auth when local auth exists
      • Verified auth source correctly switches between local and global tokens
      • All type checks, linting, and formatting checks pass
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:
      • It's somewhat self-explanatory, but I'll add create a docs PR too. Making the CI pass for now.

A picture of a cute animal (not mandatory, but encouraged)
image


Open with Devin

@roerohan roerohan requested a review from a team as a code owner February 10, 2026 10:05
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest 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

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Feb 10, 2026
@roerohan roerohan changed the title Add per-project authentication support Add per-project authentication support with wrangler login --project Feb 10, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 10, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12507

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12507

miniflare

npm i https://pkg.pr.new/miniflare@12507

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12507

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12507

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12507

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12507

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12507

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12507

wrangler

npm i https://pkg.pr.new/wrangler@12507

commit: ed84cc0

devin-ai-integration[bot]

This comment was marked as resolved.

@roerohan roerohan force-pushed the roerohan/wrangler-project-login branch from 7c2abb4 to 834b53e Compare February 10, 2026 11:23
@petebacondarwin
Copy link
Contributor

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 WRANGLER_HOME env variable.

@roerohan
Copy link
Author

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 WRANGLER_HOME env variable.

Thanks @petebacondarwin ! Happy to make changes as needed, feel free to edit my branch if you want to 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants

Comments