Skip to content

Enable IAuthenticationOperation2 to reject MSAL cached tokens and fetch new ones from ESTS - #5567

Merged
Bogdan Gavril (bgavrilMS) merged 7 commits into
bogavril/formatResultfrom
trwalke/AuthOpUpdate
Nov 13, 2025
Merged

Bogdan Gavril (bgavrilMS) merged 7 commits into
bogavril/formatResultfrom
trwalke/AuthOpUpdate

Conversation

@trwalke

@trwalke Travis Walker (trwalke) commented Nov 3, 2025

Copy link
Copy Markdown
Member

Fixes #

Changes proposed in this request
Adding Task<bool> ValidateCachedTokenAsync(MsalCacheValidationData) to IAuthenticationOperation2

This method will allow the implementation of IAuthenticationOperation2 (extensions) to validate if the cached token is still valid. If the token is not valid, this will tell MSAL to not use the token and to fetch a new one from ESTS. If the token is valid, MSAL will proceed as normal.

MsalCacheValidationData provides the data to the extension to enable it to determine if the token is valid.

Testing
Unit tests

Performance impact

Documentation

  • All relevant documentation is updated.

@bgavrilMS

Copy link
Copy Markdown
Member

Not sure what the purpose for this is, but you cannot add a method to an itnerface. See #5376

Comment thread src/client/Microsoft.Identity.Client/Microsoft.Identity.Client.csproj Outdated
@trwalke
Travis Walker (trwalke) changed the base branch from main to bogavril/formatResult November 11, 2025 23:26
@trwalke Travis Walker (trwalke) changed the title Prototype for rejecting MSAL cached token based on AuthOperation Enable IAuthenticationOperation2 to reject MSAL cached tokens and fetch new ones from ESTS Nov 12, 2025
@trwalke
Travis Walker (trwalke) marked this pull request as ready for review November 12, 2025 10:39
@trwalke
Travis Walker (trwalke) requested a review from a team as a code owner November 12, 2025 10:39
Task FormatResultAsync(AuthenticationResult authenticationResult, CancellationToken cancellationToken = default);

/// <summary>
/// Determines whether the cached token is still valid.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// Determines whether the cached token is still valid.
/// Determines whether the cached token is still valid. Only works for client_credentials flow

Co-authored-by: Gladwin Johnson <90415114+gladjohn@users.noreply.github.com>
@bgavrilMS
Bogdan Gavril (bgavrilMS) merged commit bff5d76 into bogavril/formatResult Nov 13, 2025
3 checks passed
@bgavrilMS
Bogdan Gavril (bgavrilMS) deleted the trwalke/AuthOpUpdate branch November 13, 2025 11:18
Bogdan Gavril (bgavrilMS) added a commit that referenced this pull request Dec 16, 2025
…5376)

* Fix for #5375 - Add a FormatResultAsync  to IAuthenticationOperation

* Fix

* Some comments

* fix

* doc

* Enable IAuthenticationOperation2 to reject MSAL cached tokens and fetch new ones from ESTS (#5567)

* Initial prototype

* Initial prototype

* Refactoring

* Reverting csproj changes

* Apply suggestions from code review

Co-authored-by: Gladwin Johnson <90415114+gladjohn@users.noreply.github.com>

---------

Co-authored-by: trwalke <trwalke@microsoft.com>
Co-authored-by: Bogdan Gavril <bogavril@microsoft.com>
Co-authored-by: Gladwin Johnson <90415114+gladjohn@users.noreply.github.com>

* Updating public API

---------

Co-authored-by: trwalke <trwalke@microsoft.com>
Co-authored-by: Travis Walker <travis.walker@microsoft.com>
Co-authored-by: Gladwin Johnson <90415114+gladjohn@users.noreply.github.com>
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