This fork introduces an enterprise-focused mitigation for cross-tenant authentication issues reported in:
In multi-tenant environments, users may be prompted with incomplete or incorrect login behavior when switching tenants (including tenant-specific MFA/2FA journeys), especially when cached authentication context from another tenant is reused.
File changed:
core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/TenantAwareCredential.cscore/Microsoft.Mcp.Core/src/Services/Azure/Authentication/SingleIdentityTokenCredentialProvider.cs
And intentionally preserved:
core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/CustomChainedCredential.cs
Key behavior added:
-
Isolated tenant-specific credential path
SingleIdentityTokenCredentialProvidercontinues to useCustomChainedCredentialfor default auth.- Only explicit tenant-scoped requests are routed to
TenantAwareCredential.
-
Cross-tenant cache protection
TenantAwareCredentialavoids replaying priorAuthenticationRecordvalues that may belong to a different tenant.
-
Account picker / interactive safety for tenant switching
- For explicit tenant switching,
UseDefaultBrokerAccountis suppressed and tenant-specific interactive auth is used, reducing sticky-account behavior.
- For explicit tenant switching,
-
Production-mode guardrail preserved
- Default authentication flow remains intact for non-tenant-specific paths.
- Reduces accidental token reuse across tenants.
- Encourages explicit tenant-bound login flow for MFA/2FA completion.
- Maintains secure non-interactive behavior for production workloads.
- This change is an incremental hardening attempt for tenant-switch reliability and MFA redirect handling.
- Final behavior can vary by host OS account broker, Entra tenant policy, and credential chain settings.