Repository navigation
Scope OIDC issuer fallback eligibility - #978
Open
Nilesh Choudhary (4gust) wants to merge 3 commits into
Open
Nilesh Choudhary (4gust) wants to merge 3 commits into
Nilesh Choudhary (4gust) wants to merge 3 commits into
Conversation
Restrict regional issuer patterns to built-in Microsoft authorities and prevent their CIAM/B2C fallback. Preserve native parsing behavior, reject before endpoint use, and evict rejected discovery metadata for recovery. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Issuer-validation exceptions bypass cache eviction, leaving malformed HTTP 200 metadata cached for 24 hours and preventing recovery with the same cache even after metadata is corrected.
1 open issue
What changed in this PR
This PR tightens issuer fallback eligibility for explicit oidc_authority in MSAL Python while preserving ordinary authority behavior and existing URL parsing.
Changes:
- Limits regional issuer fallback to built-in Microsoft authorities and disables their B2C/CIAM fallback.
- Moves issuer validation before endpoint consumption and adds cache eviction for rejected issuers.
- Adds policy, boundary, and recovery tests, plus documentation of the behavior change.
| File | Description |
|---|---|
| tests/test_authority.py | Adds issuer-policy, parsing-boundary, and cache-recovery coverage. |
| RELEASES.md | Documents compatibility changes and their scope. |
| msal/throttled_http_client.py | Extracts GET cache-key generation and adds targeted eviction. |
| msal/authority.py | Restricts fallback eligibility and validates issuers before using endpoints. |
| msal/application.py | Documents explicit OIDC issuer validation and cache behavior. |
Review effort: Balanced
Evict rejected discovery metadata when issuer parsing raises, without changing the original exception. Cover repeated malformed-issuer rejection, valid recovery, and accepted metadata caching. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
_ExpiringMapping.pop() leaves orphaned expiry-heap records, allowing repeated rejected constructions with a shared HTTP cache to grow the in-memory or serialized cache beyond the 1,024-entry limit.
1 open issue
1 resolved since last review
Review effort: Balanced
Invalidate rejected responses and rebuild the expiry heap from live entries under the existing cache lock. Preserve accepted responses, expiry ordering, and capacity eviction without accumulating orphans. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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
Validation
python -m pytest tests\test_authority.py tests\test_application.py tests\test_throttled_http_client.py tests\test_individual_cache.py -q --tb=short231 passed, 1 pre-existing skip; 308 subtests passed (Windows, Python 3.12.10).