You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request adds issuer validation for OpenID Connect (OIDC)
discovery in the `@azure/msal-common` package, ensuring that the issuer
returned from the OIDC discovery document matches authority set by the
application for security and correctness. It also introduces a new error
code for issuer validation failures and updates internal metadata and
documentation accordingly.
**OIDC Issuer Validation Enhancements:**
* Added a `validateIssuer` private method to the `Authority` class in
`Authority.ts` to enforce issuer validation based on OIDC and
Microsoft-specific rules. This method checks that the issuer from the
discovery document matches the authority or known Microsoft hosts,
including support for regional and CIAM tenant patterns. If validation
fails, a `ClientConfigurationError` is thrown.
* Integrated the new `validateIssuer` method into the OIDC discovery
flow within the `Authority` class to ensure issuer validation is
performed after discovery metadata is fetched.
**Error Handling and Codes:**
* Introduced a new error code `issuerValidationFailed` in
`ClientConfigurationErrorCodes` and exported it for use when issuer
validation fails.
[[1]](diffhunk://#diff-b8eec2047e45982117c70657c616ab76429becdd5a52b4dd168670cce0688352R29)
[[2]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L1584-R1585)
[[3]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117R2905-R2909)
**Metadata and Test Updates:**
* Added new metadata for the PPE environment in `AuthorityMetadata.ts`
to support additional authority hosts.
**Documentation and API Review:**
* Updated the API review file (`msal-common.api.md`) to reflect the new
error code, document the new method, and adjust line references for
TSDoc warnings.
[[1]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L1584-R1585)
[[2]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117R2905-R2909)
[[3]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L4825-R4837)
**Release and Change Tracking:**
* Added a change file describing the patch and referencing the related
issue and PR for tracking.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lalimasharda <26092202+lalimasharda@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/errors.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,6 +268,9 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt
268
268
### `invalid_request_method_for_EAR`
269
269
- The EAR protocol cannot be used with HTTP method `GET`. The `httpMethod` parameter in all requests using `protocolMode: ProtocolMode.EAR` must be either unset or `"POST"`/`HttpMethod.POST`.
270
270
271
+
### `issuer_validation_failed`
272
+
- Issuer returned from OpenID configuration endpoint does not match with the authority configured by the application.
@@ -2901,6 +2902,11 @@ function isServerTelemetryEntity(key: string, entity?: object): boolean;
2901
2902
// @public
2902
2903
function isSingleTenant(accountEntity:AccountEntity):boolean;
2903
2904
2905
+
// Warning: (ae-missing-release-tag) "issuerValidationFailed" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// src/authority/Authority.ts:464:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4823
4829
// src/authority/Authority.ts:465:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4824
4830
// src/authority/Authority.ts:500:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4825
-
// src/authority/Authority.ts:579:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4826
-
// src/authority/Authority.ts:653:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4827
-
// src/authority/Authority.ts:691:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4828
-
// src/authority/Authority.ts:802:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4829
-
// src/authority/Authority.ts:1000:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4831
+
// src/authority/Authority.ts:582:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4832
+
// src/authority/Authority.ts:656:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4833
+
// src/authority/Authority.ts:694:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4834
+
// src/authority/Authority.ts:805:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4835
+
// src/authority/Authority.ts:1003:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4836
+
// src/authority/Authority.ts:1218:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4830
4837
// src/authority/AuthorityOptions.ts:25:5 - (ae-forgotten-export) The symbol "CloudInstanceDiscoveryResponse" needs to be exported by the entry point index.d.ts
4831
4838
// src/cache/CacheManager.ts:355:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4832
4839
// src/cache/CacheManager.ts:356:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
Copy file name to clipboardExpand all lines: lib/msal-common/docs/authority.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,14 @@ The authority URL guides MSAL where to look for the 3 endpoints that are require
24
24
25
25
> :bulb: Certain OAuth 2.0 grants may skip the authorize endpoint and go directly for the token endpoint, e.g. [OAuth 2.0 Client Credentials Grant](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow)
26
26
27
+
## Issuer validation
28
+
29
+
When MSAL retrieves the OpenID configuration document from the network, it validates the `issuer` field returned by the IdP against the configured authority, per the [OpenID Connect Discovery 1.0 spec](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation). This protects against accepting metadata from a malicious or misconfigured service that hosts an OpenID configuration document under an unrelated domain. The issuer is accepted when its scheme and host (and port) match the configured authority, or — for Microsoft cloud authorities — when it is HTTPS and its host is a known Microsoft authority host (including regional variants and `{tenant}.ciamlogin.com` patterns).
30
+
31
+
If the issuer does not satisfy these conditions, MSAL throws a `ClientConfigurationError` with error code `issuer_validation_failed` and the authentication flow is aborted. This validation is applied only to OpenID configuration documents fetched from the network — cached, hardcoded, and config-supplied metadata are not re-validated.
32
+
33
+
> Warning: An IdP whose `issuer` does not satisfy the conditions above will fail discovery. If you are using a non-Microsoft OIDC provider whose issuer does not exactly match the authority host you configured, ensure the authority you pass to MSAL has the same scheme and host as the value the IdP returns in its discovery document.
0 commit comments