Repository navigation
Do not carry authority port to global instance discovery - #6155
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes instance discovery URL construction so that a custom authority port is not propagated when MSAL redirects instance discovery to the global discovery host, while still preserving the custom port for authorization/token endpoints.
Changes:
- Update instance discovery endpoint computation to only apply the authority’s custom port when discovery targets the same host.
- Align the shared instance discovery mock helper with the new endpoint behavior.
- Update/rename the custom-port regression unit test to validate “no port on global discovery” behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Microsoft.Identity.Test.Unit/CoreTests/InstanceTests/AadAuthorityTests.cs | Updates the regression test to ensure custom port is preserved for authority usage but not applied to global instance discovery. |
| src/client/Microsoft.Identity.Lab.Api/Http/MockHttpManagerExtensions.cs | Adjusts discovery mock URL construction to mirror the new “port only when same host” logic. |
| src/client/Microsoft.Identity.Client/Instance/Discovery/NetworkMetadataProvider.cs | Fixes production instance discovery endpoint creation to avoid carrying the authority port to the global discovery host. |
Gladwin Johnson VR (gladjohn)
approved these changes
Jul 31, 2026
Bogdan Gavril (bgavrilMS)
force-pushed
the
fix/6154-global-discovery-port
branch
from
September 15, 2026 12:47
4d40697 to
99ce0e6
Compare
Copilot started reviewing on behalf of
Bogdan Gavril (bgavrilMS)
September 15, 2026 13:17
View session
Copilot started reviewing on behalf of
Bogdan Gavril (bgavrilMS)
September 15, 2026 15:54
View session
Bogdan Gavril (bgavrilMS)
force-pushed
the
fix/6154-global-discovery-port
branch
from
September 15, 2026 17:26
7ed8c5a to
d3af94d
Compare
Nilesh Choudhary (4gust)
approved these changes
Sep 16, 2026
Use a custom authority port only when instance discovery targets the same host. Preserve the port on the authority itself for authorization and token requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8fd80bfc-67a0-4961-86f7-e911aaebfc13
Add direct network-provider regression coverage requested in PR review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 523c427f-a9a4-435d-a330-be66fc474897
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 073961ec-5315-4e60-a0c0-fd264fb0c055
Bogdan Gavril (bgavrilMS)
force-pushed
the
fix/6154-global-discovery-port
branch
from
September 17, 2026 14:21
d3af94d to
d1c776c
Compare
Copilot started reviewing on behalf of
Bogdan Gavril (bgavrilMS)
September 17, 2026 14:22
View session
Bogdan Gavril (bgavrilMS)
deleted the
fix/6154-global-discovery-port
branch
September 17, 2026 16:46
This was referenced Oct 5, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6154
Testing
dotnet build src\client\Microsoft.Identity.Client\Microsoft.Identity.Client.csproj --framework net8.0 --no-restore --verbosity quietReview follow-up
Added a direct network-provider test proving a custom port is retained when discovery uses the authority host.
Local targeted tests were attempted on net8.0 and net48. Execution was blocked by an MSTest adapter get_DataRow implementation error on net8.0 and a missing System.Memory assembly on net48. Cleaning net8.0 outputs and restoring dependencies did not resolve the net8.0 runner error. No passing test result is claimed.
Added a negative regression test with no custom discovery endpoint supplied to MSAL or the mock helper. For https://localhost:5215/common/, it explicitly asserts the discovery host, port 443, and full endpoint path.
Re-ran the three targeted custom-port tests on net8.0 and net48; execution remains blocked by the runner errors noted above.
assistance: agentic-cli
type: bug
agent-tool: copilot-cli
agent-model: gpt-6-astra
work-item: AB#n/a