Skip to content

POC: Synchronous result-based validation fast path for issuer (#3459)#3538

Open
debchoudhury-id4s wants to merge 1 commit into
westin/poc-basefrom
debchoudhury/sync-validation
Open

POC: Synchronous result-based validation fast path for issuer (#3459)#3538
debchoudhury-id4s wants to merge 1 commit into
westin/poc-basefrom
debchoudhury/sync-validation

Conversation

@debchoudhury-id4s

@debchoudhury-id4s debchoudhury-id4s commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds a synchronous validation path to the experimental model, scoped to the issuer check (#3459). When the configuration is already cached (or no ConfigurationManager is set), validation runs without the per-call Task and configuration awaits. The shipped TokenValidationParameters path and the async path are unchanged.

The goal is to keep this as a POC and capture benchmarking results comparing the synchronous and asynchronous paths.

Changes

  • BaseConfigurationManager.TryGetCurrentConfiguration(out BaseConfiguration?) — synchronous config peek; base returns false, ConfigurationManager<T> overrides it and reuses the async fast-path predicate so the two can't drift.
  • ISynchronousIssuerValidator + Validators.ValidateIssuer/ValidateIssuerInternal — synchronous issuer validation on the peeked config, implemented by DefaultIssuerValidator.
  • JsonWebTokenHandler.ValidateToken(...) + private ValidateJWS/ValidateJWE — synchronous pipeline; runs sync on a cache hit, otherwise falls back to ValidateTokenAsync. Records last-known-good on success.
  • PublicAPI.Unshipped.txt, CHANGELOG.md, and ValidateTokenSyncTests (sync vs async golden master, including a cache-hit case).

Validation

Build clean (0 warnings, 0 errors) on all target frameworks. Microsoft.IdentityModel.Tokens.Tests, Microsoft.IdentityModel.JsonWebTokens.Tests, and Microsoft.IdentityModel.Protocols.Tests pass.

@debchoudhury-id4s
debchoudhury-id4s requested a review from a team as a code owner July 8, 2026 17:33
@Toidi357

Toidi357 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

I think this is related to my intern project. I'm also working on making a synchronous result-based validation method ValidateToken, but doesn't have any asynchronous fallback. Async fallback creates sync-over-async (when you do .GetAwaiter().GetResult() issues which I'm hoping to avoid by adding methods to HttpDocumentRetriever, ConfigurationManager, and other related classes

@debchoudhury-id4s
debchoudhury-id4s force-pushed the debchoudhury/sync-validation branch 2 times, most recently from 572bed6 to 3d01ac6 Compare July 9, 2026 18:51
@westin-m westin-m linked an issue Jul 9, 2026 that may be closed by this pull request
@debchoudhury-id4s

Copy link
Copy Markdown
Contributor Author

perf results are in Perf Comparison synchronous validation POC.docx.

TL;DR the POC is safe to be merged (not saying we should NOW). Check section 2 which does a sync vs async comparison showing how the POC reduces latency and improves perf

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@debchoudhury-id4s
debchoudhury-id4s force-pushed the debchoudhury/sync-validation branch from 3d01ac6 to 6f04adb Compare July 20, 2026 00:11
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.

POC Inconsistent API surface regarding sync vs async methods

2 participants