Skip to content

Add issuer validation when making call to OIDC endpoint #5358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Avery-Dunn
Copy link
Contributor

This PR adds issuer validation for OIDC scenarios: 3268765

  • When using the WithOidcAuthority() API, a call is made to the OIDC discovery endpoint based on the authority set for the application
  • Part of the response is an expected issuer, and if this issuer differs from what we expect based on the authority we will throw an exception.

As per OAuth spec, an issuer is valid if it matches the authority. In addition to the standard spec, there is also special validation for CIAM-style issuers which will mainly be relevant when using custom authorities in a CIAM scenario.

@Avery-Dunn Avery-Dunn requested a review from a team as a code owner June 23, 2025 21:34
Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

LGTM, but we should understand if WithOidcAuthority(Entra) will work on not (via tests). Id.Web might be using this API.

httpManager.AddMockHandler(new MockHttpMessageHandler
{
ExpectedMethod = HttpMethod.Get,
ExpectedUrl = authority + "/" + Constants.WellKnownOpenIdConfigurationPath,
Copy link
Contributor

Choose a reason for hiding this comment

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

should you use template literal here?

$"{authority}/{Constants.WellKnownOpenIdConfigurationPath}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It now uses that literal, as well as the generic authority value found in TestConstants

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.

5 participants