Skip to content

Scope OIDC issuer fallback eligibility - #978

Open
Nilesh Choudhary (4gust) wants to merge 3 commits into
devfrom
4gust-python-issuer-validation
Open

Nilesh Choudhary (4gust) wants to merge 3 commits into
devfrom
4gust-python-issuer-validation

Conversation

@4gust

Copy link
Copy Markdown
Contributor

Summary

  • Restrict regional issuers to built-in Microsoft authorities and prevent their CIAM/B2C fallback; preserve existing URL parsing behavior.
  • Reject before endpoint use, evict rejected discovery metadata, and cover S01–S08 plus boundary/recovery cases.
  • Document the behavior change.

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=short

231 passed, 1 pre-existing skip; 308 subtests passed (Windows, Python 3.12.10).

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>
@4gust
Nilesh Choudhary (4gust) requested a review from a team as a code owner October 29, 2026 15:09
Copilot AI balanced review requested due to automatic review settings October 29, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread msal/authority.py Outdated
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>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread msal/throttled_http_client.py Outdated
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>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the issuer-fallback restrictions and metadata cache-recovery changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants