Skip to content

Fix credential collision when connecting two Server/Data Center sites with the same PAT username - #1933

Open
luisdat wants to merge 3 commits into
atlassian:mainfrom
luisdat:upstream-pat-credential-fix-v2
Open

Fix credential collision when connecting two Server/Data Center sites with the same PAT username#1933
luisdat wants to merge 3 commits into
atlassian:mainfrom
luisdat:upstream-pat-credential-fix-v2

Conversation

@luisdat

@luisdat luisdat commented Aug 24, 2026

Copy link
Copy Markdown

Summary

saveDetailsForSite in src/atlclients/loginManager.ts computed the stored credential ID's siteId as site.product.key (e.g. "jira") for PAT (Personal Access Token) logins, instead of the site host — unlike Basic Auth, which already used the host:

const siteId = isBasicAuthInfo(credentials) ? baseLinkUrl : site.product.key;

Two different Jira or Bitbucket Server/Data Center instances authenticated via PAT with the same username therefore hash to the identical credential ID (CredentialManager.generateCredentialId is md5(siteId::username)), so connecting a second such site silently overwrites the first site's stored token — both in the in-memory credential store and in VS Code SecretStorage. The first site then fails auth on its next request and gets marked invalid/disconnected.

This is easy to hit in practice: any organization running multiple on-prem Jira/Bitbucket instances where users authenticate with the same corporate/LDAP username on each.

saveDetailsForSite is only ever used for Server/Data Center (non-cloud) sites, so the fix always scopes the credential ID to the site's host, matching the existing Basic Auth behavior:

const siteId = baseLinkUrl;

The OAuth/cloud shared-credential-per-account behavior (a separate, deliberate design for cloud accounts with multiple accessible resources) lives elsewhere and is untouched by this change.

Test plan

  • Added a regression test in src/atlclients/loginManager.test.ts verifying two different Server/DC hosts sharing the same PAT username now produce distinct credential IDs.
  • npm test -- src/atlclients/loginManager.test.ts src/atlclients/authStore.test.ts passes.
  • Manually verified: connected two separate Jira Data Center instances via PAT with the same username; both now stay connected simultaneously (previously the first would disconnect with an auth error as soon as the second was added).

(Reopened as a fresh PR to replace #1932, which had a CLA-check issue.)


Rovo Dev code review: Rovo Dev couldn't review this pull request
The pull request author does not have access to Rovo Dev.

saveDetailsForSite computed the stored credential ID's siteId as
site.product.key (e.g. "jira") for PAT logins instead of the site
host, unlike Basic Auth which already used the host. Two different
Jira/Bitbucket Server or Data Center instances authenticated via PAT
with the same username therefore hashed to the identical credential
ID, so connecting a second such site silently overwrote the first
site's stored token in both the in-memory store and SecretStorage.
The first site would then fail with an auth error and appear
disconnected.

This method is only ever used for Server/DC (non-cloud) sites, so the
credential ID is now always scoped to the site's host, matching the
Basic Auth behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant