Add OIDC Issuer Validation #865
Closed
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.
Add OIDC Issuer Validation for Enhanced Security
Problem
When using OIDC authority URLs, MSAL Python was not validating the
issuerclaim from the OIDC discovery response. Per the OpenID Connect Discovery specification, the issuer returned in the discovery document should be validated. Without this validation, applications could be vulnerable to accepting tokens from unauthorized identity providers.Solution
Added issuer validation when initializing an authority with
oidc_authority_url:New
TRUSTED_ISSUER_HOSTSconstant - A frozenset of well-known Microsoft identity provider hosts:login.microsoftonline.com,login.microsoft.com,login.windows.net,sts.windows.netlogin.chinacloudapi.cn,login.partner.microsoftonline.cn,login.microsoftonline.de,login.microsoftonline.us,login.usgovcloudapi.net,login-us.microsoftonline.comNew
_validate_issuer()function - Validates the issuer claim with O(1) lookups:westus2.login.microsoft.comValidation is called only for OIDC authorities - Standard Entra authorities continue to work without additional validation
Files Changed
msal/authority.py- AddedTRUSTED_ISSUER_HOSTS,_validate_issuer()function, and validation callBreaking Changes
Applications using
oidc_authorityparameter will now require the OIDC discovery response to include a validissuerclaim that either: