Skip to content

azrepos: make shared token cache configurable - #2415

Open
mjcheetham wants to merge 2 commits into
git-ecosystem:mainfrom
mjcheetham:shared-cache-optional
Open

azrepos: make shared token cache configurable#2415
mjcheetham wants to merge 2 commits into
git-ecosystem:mainfrom
mjcheetham:shared-cache-optional

Conversation

@mjcheetham

Copy link
Copy Markdown
Contributor

Azure Repos OAuth tokens currently always use the shared Microsoft developer tooling cache. While this enables authentication reuse across GCM, Visual Studio, and Azure CLI, users have no way to isolate GCM's authentication state.

Allow users to select a GCM-specific token cache through Git configuration or an environment variable. Keep the shared cache as the default to preserve existing behaviour and document the interoperability and opt-out semantics.

@mjcheetham
mjcheetham requested a review from a team as a code owner August 24, 2026 12:36
@mjcheetham mjcheetham added host:azure-repos Specific to the Azure Repos (Azure DevOps, VSTS) host provider auth:entra Specific to Microsoft Entra Authentication labels Aug 24, 2026
@mjcheetham
mjcheetham requested review from mpysson and a balanced review from Copilot August 24, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable Azure Repos token-cache isolation while preserving shared-cache behavior by default.

Changes:

  • Adds Git and environment settings for cache selection.
  • Extends diagnostics to validate both caches.
  • Documents interoperability and opt-out behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Microsoft.AzureRepos/AzureReposHostProvider.cs Applies the cache setting to Entra authentication.
src/Microsoft.AzureRepos/AzureDevOpsConstants.cs Defines the new setting names.
src/Core/Diagnostics/EntraAuthenticationDiagnostic.cs Diagnoses both token caches.
src/Core/Commands/DiagnoseCommand.cs Formats aggregate diagnostic exceptions.
docs/environment.md Documents the environment variable.
docs/configuration.md Documents the Git configuration option.
docs/azrepos-users-and-tokens.md Explains shared-cache opt-out behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Microsoft.AzureRepos/AzureReposHostProvider.cs
Comment thread docs/environment.md Outdated
Azure Repos OAuth tokens currently always use the shared Microsoft
developer tooling cache. While this enables authentication reuse across
GCM, Visual Studio, and Azure CLI, users have no way to isolate GCM's
authentication state.

Allow users to select a GCM-specific token cache through Git
configuration or an environment variable. Keep the shared cache as the
default to preserve existing behaviour and document the interoperability
and opt-out semantics.

Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
The Entra diagnostic only exercises the shared Microsoft developer
tools cache. Problems with GCM's application-specific cache can
therefore go undetected, while stopping at the first failure would hide
the state of the other cache.

Run the persistence checks for both caches and collect their failures
independently. Flatten aggregate exceptions in the diagnostic log so
each cache-specific failure remains visible while the diagnostic still
reports a single failure.

Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
@mjcheetham
mjcheetham force-pushed the shared-cache-optional branch from 40e1e3f to 3bfb07f Compare August 26, 2026 16:11
log.AppendLine($"CacheDirectory: {cacheProps.CacheDirectory}");
log.AppendLine($"CacheFileName: {cacheProps.CacheFileName}");
log.AppendLine($"CacheFilePath: {cacheProps.CacheFilePath}");
await RunCacheDiagnosticAsync("Shared Microsoft developer tools", true, log, failures);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagnostic now tests both caches and throws if either fails. Consequently, a user who explicitly selects the GCM-specific cache can still get a failed git-credential-manager diagnose result solely because the unused shared cache is inaccessible, and vice versa. This is especially misleading because DiagnoseCommand reports that failures indicate an installation problem.

Consider logging results for both caches but making only the configured cache determine diagnostic success, or registering each cache check as a separate diagnostic so the relevant and optional failures are distinguishable.

Comment thread docs/configuration.md
Comment on lines +830 to +835
### credential.azreposUseMicrosoftSharedCache

Use the token cache shared by Microsoft developer tools when authenticating to
Azure Repos with Microsoft identity OAuth tokens. This allows GCM to reuse
authentication performed by tools such as Visual Studio and Azure CLI, and
allows those tools to reuse authentication performed by GCM.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These additions say the selected cache allows authentication reuse with Azure CLI. Azure CLI maintains its own cache under $AZURE_CONFIG_DIR/msal_token_cache.{bin,json}, rather than the .IdentityService/msal.cache cache configured here. Any broker-based SSO on supported systems is separate from sharing this cache and may still occur when this option is disabled.

Remove Azure CLI from these examples or describe the narrower set of tools that actually consume the Microsoft developer shared cache.

Comment thread docs/environment.md

---

### GCM_AZREPOS_USE_MSFT_CACHE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

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

Labels

auth:entra Specific to Microsoft Entra Authentication host:azure-repos Specific to the Azure Repos (Azure DevOps, VSTS) host provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants