Skip to content
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

New validation model: Preview docs #3108

Open
wants to merge 4 commits into
base: feature/new-validation-model
Choose a base branch
from

Conversation

iNinja
Copy link
Contributor

@iNinja iNinja commented Jan 30, 2025

New validation model: Preview docs

  • Added extra benchmark to highlight the performance difference in failure scenarios.
  • Added initial markdown document for the new validation model.
  • Updated E2E tests to access the new validation method through the experimental interface

Part of #2711

@iNinja iNinja requested a review from a team as a code owner January 30, 2025 18:09
@@ -0,0 +1,86 @@
# New token validation model
Copy link
Collaborator

Choose a reason for hiding this comment

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

this would move to the wiki, in a page there. identityModel has the docs generally there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I included it in the PR for review. Should we remove the file from the repo and just send it to the wiki?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes please! thanks @iNinja

Copy link
Contributor

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

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

Looks great!
I proposed a few tweaks.

@@ -29,7 +30,7 @@ public async Task TestDefaultValidToken()
};
CallContext callContext = new CallContext();

ValidationResult<ValidatedToken> validationResult = await jsonWebTokenHandler.ValidateTokenAsync(token, validationParameters, callContext, default);
ValidationResult<ValidatedToken> validationResult = await ((IResultBasedValidation)jsonWebTokenHandler).ValidateTokenAsync(token, validationParameters, callContext, default);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having casts everywhere, can we have a private get property returning this?

@@ -0,0 +1,86 @@
# New token validation model
The existing token validation model on `Microsoft.IdentityModel` relies on the exception based control flow dominant in C#. In some high-performance scenarios where latency is key, this can cause unintended increases when validations fail and throw.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "dominant in C#" mean?

There is another point which is that where trying several authentication schemes in ASP.NET Core, if one fails and the next succeeds, an error is still logged (which is confusing for developers). In other words the logs can make the decision too early to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant to say that the exception based control flow is the most common way to perform control flow in C#.
Other languages/frameworks have options at times, but here I would dare say over 90% of the codebases follow this approach as it is the norm.

Applied documentation suggestions with small changes.
@jennyf19
Copy link
Collaborator

jennyf19 commented Feb 9, 2025

@iNinja the package shipped last week, are you planning on merging this and updating the wiki?

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.

3 participants