-
Notifications
You must be signed in to change notification settings - Fork 5k
Ensure TenantIdResolver performs case-insensitive tenant ID comparisons #51694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: christothes <[email protected]>
…r change Co-authored-by: christothes <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the TenantIdResolver
to perform case-insensitive tenant ID comparisons, making authentication more resilient to casing differences that may occur in WWW-Authenticate challenges.
- Updated all string comparisons in
TenantIdResolver.cs
to useStringComparison.OrdinalIgnoreCase
- Added comprehensive test coverage with three new test methods to verify case-insensitive behavior
- Updated the changelog to document the bug fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
sdk/identity/Azure.Identity/src/TenantIdResolver.cs | Updated four string comparison operations to use case-insensitive comparison |
sdk/identity/Azure.Identity/tests/TenantIdResolverTests.cs | Added three new test methods to verify case-insensitive tenant ID handling |
sdk/identity/Azure.Identity/CHANGELOG.md | Added entry documenting the case-insensitive tenant ID comparison fix |
/check-enforcer override |
This PR updates the
TenantIdResolver
to perform case-insensitive tenant ID comparisons, making it more resilient to odd casing that may come from WWW-Authenticate challenges.Problem
The
TenantIdResolver.Resolve
method was performing case-sensitive comparisons when validating and resolving tenant IDs. This could cause issues when tenant ID values returned from WWW-Authenticate challenges have different casing than expected.Solution
Updated all string comparisons in
TenantIdResolver.cs
to useStringComparison.OrdinalIgnoreCase
:context.TenantId != explicitTenantId
to use case-insensitive comparisonexplicitTenantId == Constants.AdfsTenantId
comparisons to be case-insensitiveresolvedTenantId != explicitTenantId
to use case-insensitive comparisonTesting
Added comprehensive test coverage with three new test methods:
ResolveWithCaseInsensitiveTenantIdComparison
: Verifies mixed case tenant IDs are handled correctlyResolveWithCaseInsensitiveAdfsTenantId
: Tests that ADFS tenant ID detection works with various casings (ADFS, adfs, Adfs)ResolveWithCaseInsensitiveComparisonForAllowedTenants
: Ensures case-insensitive matching against additionally allowed tenantsAll existing tests continue to pass, confirming no regressions were introduced.
Example
Previously, these would be treated as different tenants:
Now these comparisons work correctly regardless of casing differences.
Fixes #51693.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.