Repository navigation
Harden regional authority validation - #650
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ce37b127-6ff1-4e36-80e5-c74d574905ce
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ce37b127-6ff1-4e36-80e5-c74d574905ce
|
Avery-Dunn
approved these changes
Aug 12, 2026
Gladwin Johnson VR (gladjohn)
approved these changes
Aug 12, 2026
Robbie-Microsoft
added a commit
that referenced
this pull request
Aug 18, 2026
origin/main gained "Harden regional authority validation (#650)", which tightens validRegion to a DNS-label pattern, validates the caller-supplied region in AADInstanceDiscovery and the IMDS response in parseRegionFromIMDSResponse, and replaces detectRegion's normalization of REGION_NAME (strip spaces, lowercase) with outright rejection of a value that is not a valid region. CI builds refs/pull/632/merge, so it tested this combination while local verification tested only the branch head. That is why TestDetectRegionEnvironmentIsNotMemoized went red on CI while passing locally: its second value, "WEST US 2", relied on the normalization #650 removed. The three-way merge is textually clean because this branch's authority.go changes are purely additive (70 insertions, 0 deletions) and never touch a line #650 rewrote. The merged detectRegion therefore keeps upstream's validation of the environment variable and this branch's memoization of the IMDS probe only. Both properties are intended, and both are covered by tests. Test changes: - TestDetectRegionEnvironmentIsNotMemoized exists to pin that REGION_NAME is re-read rather than cached, which is orthogonal to normalization. Its second value becomes "westus2" and the now-false comment about spaces being stripped and the value lowercased is removed. The test still fails if memoization of the environment variable is reintroduced. - TestDetectRegionBlankEnvironmentResolvesToNothing and, in the confidential package, acquireForRegionDiscovery both still pass, but for a different reason: a blank REGION_NAME is now rejected as invalid rather than stripped to empty. Their comments described the old mechanism and are corrected. What they assert is unchanged. - Adds TestMtlsPoPInvalidForceRegionIsRejectedBeforeHTTP, the mTLS PoP analogue of #650's TestInvalidMSALForceRegionIsRejectedBeforeHTTP: an invalid MSAL_FORCE_REGION fails the acquisition before any request is made, with instance discovery disabled. MtlsTokenEndpoint interpolates the region into the token host without validating it, so this guarantee rests on endpoint resolution reaching AADInstanceDiscovery; the test pins it end to end rather than pinning that mechanism. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Robbie-Microsoft
added a commit
that referenced
this pull request
Aug 18, 2026
…he FIC branch Brings in e17ec6d, which merged origin/main (946d51a, "Harden regional authority validation (#650)") into #632. #650 replaced detectRegion's space-stripping and lowercasing with strict validRegion rejection; the parent already reconciled that against our memoization and fixed the test that asserted the deleted stripping behavior, so nothing needed re-fixing here. No conflicts. Every file this merge touches -- authority.go, authority_test.go, region_test.go, confidential_region_discovery_test.go, confidential_test.go, and the new confidential_mtls_region_validation_test.go -- is byte-identical to e17ec6d, so the region reconciliation stays uniform across the stack. The FIC branch's mTLS PoP ordering divergence is untouched: e17ec6d does not modify confidential.go or confidential_mtls_validation_test.go, so AuthorityInfo.ValidateMtlsPoP() still runs before prepareMtlsPoP, with the comment explaining why, and both pins from e175bb9 still pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
REGION_NAMEand IMDS regions so discovery falls back to global behaviorTesting
go test ./apps/internal/oauth/ops/authority -count=1