-
Notifications
You must be signed in to change notification settings - Fork 403
Expose refresh token via extension and add CacheOptions.DisableInternalCache #5947
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
Merged
Robbie-Microsoft
merged 39 commits into
main
from
rginsburg/mtls_expose_refresh_token_and_add_disableInternalCache
Apr 30, 2026
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
cc2ce8b
feat: expose refresh token via extension and add CacheOptions.Disable…
Robbie-Microsoft f27c85b
style: remove AC# labels and section comment from test summaries
Robbie-Microsoft 19c0bf1
Address Copilot review: guard all cache read methods, use Verbose log…
Robbie-Microsoft 3e63f55
Address Bogdan and Gladwin review comments
Robbie-Microsoft d0a89b3
refactor: address Copilot review feedback on PR #5947
Robbie-Microsoft 59bc826
feat: gate RefreshToken exposure on confidential client only
Robbie-Microsoft 8eaf5c7
test: add GetRefreshToken_PublicClient_ReturnsNull to confirm RT is n…
Robbie-Microsoft 9b43d4c
refactor: address Copilot comments - centralize error message and use…
Robbie-Microsoft daed48d
Add code review comment on redundant cache-disabled check pattern
gladjohn 4a22470
fix: throw MsalUiRequiredException instead of MsalClientException for…
Robbie-Microsoft d5d3fb2
Revert "Add code review comment on redundant cache-disabled check pat…
Robbie-Microsoft 0b417c3
docs: add method signature to GetRefreshToken cref for reliable doc r…
Robbie-Microsoft 3b6ba8e
docs: clarify GetRefreshToken guidance applies to confidential client…
Robbie-Microsoft d5eafc3
Fix OBO integration test: assert null RT for normal OBO flow
Robbie-Microsoft daa4755
Rename OBO test to match its null-RT assertions
Robbie-Microsoft ca67dda
Potential fix for pull request finding
Robbie-Microsoft a4d1f30
docs: expand CacheOptions.DisableInternalCache XML docs to mention ca…
Copilot 5daefd4
Improve DisableInternalCache docs, fix GetTenantProfilesAsync guard, …
Robbie-Microsoft a696c93
test: add OBO + CCA unit tests for DisableInternalCache; remove integ…
Robbie-Microsoft fc0e00d
feat: add CacheRefreshReason.CacheDisabled telemetry for DisableInter…
Robbie-Microsoft 3316031
fix: address Copilot review comments
Robbie-Microsoft d9953c9
fix: remove unused usings and orphaned KV fields from SilentAuthTests…
Robbie-Microsoft c6f8f14
Add telemetry tests for CacheRefreshReason.CacheDisabled
Robbie-Microsoft 4fde7b3
Fix Copilot comments: remove unused using, short-circuit EntryCount w…
Robbie-Microsoft 3b711cd
Address Neha's feedback: restore comment, consolidate OBO telemetry, …
Robbie-Microsoft efab63c
Populate TenantProfiles from ID token when internal cache is disabled
Robbie-Microsoft 505f7f4
Rename useCacheOptions parameter to cacheOptions in OTelInstrumentati…
Robbie-Microsoft fc32179
Refactor: IsInternalCacheDisabled helper on RequestBase; doc + test i…
Robbie-Microsoft 645b046
Refactor: CacheOptions.IsDisabledFor helper; tighten OBO disabled-cac…
Robbie-Microsoft fa83577
Minor: use CacheOptions.IsDisabledFor in validation; fix test doc; ad…
Robbie-Microsoft bec7607
Fix assertion message typo: IsInternalCacheDisabled -> MsalError.Inte…
Robbie-Microsoft 246a214
Update src/client/Microsoft.Identity.Client/MsalErrorMessage.cs
Robbie-Microsoft 77f2e1f
Update src/client/Microsoft.Identity.Client/MsalError.cs
Robbie-Microsoft a7e7ec4
Fix: fully-qualify CacheOptions cref in AuthenticationResultExtension…
Robbie-Microsoft 18a544c
Fix: throw at config time when DisableInternalCacheOptions is set on …
Robbie-Microsoft 98682d1
Merge remote-tracking branch 'origin/main' into rginsburg/mtls_expose…
Robbie-Microsoft 2f11fe9
Fix: update GetRefreshToken() doc to reflect RT may come from request…
Robbie-Microsoft 3d12ae1
Merge main into branch; resolve PublicAPI.Unshipped.txt conflicts
Robbie-Microsoft 7f12f0c
Fix: remove redundant null check in WithCacheOptions; restore PublicA…
Robbie-Microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/client/Microsoft.Identity.Client/Extensibility/AuthenticationResultExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Microsoft.Identity.Client.Extensibility | ||
| { | ||
| /// <summary> | ||
| /// Extension methods for <see cref="AuthenticationResult"/>. | ||
| /// </summary> | ||
| public static class AuthenticationResultExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns the refresh token from the authentication result, if available. | ||
| /// This is intended for advanced scenarios where the caller manages its own token cache, | ||
| /// for example when using <see cref="Microsoft.Identity.Client.CacheOptions.DisableInternalCacheOptions"/>. | ||
| /// </summary> | ||
| /// <param name="result">The authentication result.</param> | ||
| /// <returns> | ||
| /// The refresh token string associated with the result for confidential client flows, if available. | ||
| /// This may be a refresh token returned in the token response or a refresh token used for the | ||
| /// acquisition and carried on the result; <c>null</c> otherwise. Refresh tokens are not exposed | ||
| /// for public client flows, client credentials, managed identity, or when the token was | ||
| /// served from cache. For the normal (non-long-running) On-Behalf-Of flow, MSAL intentionally | ||
| /// clears the refresh token, so this method will also return <c>null</c>. | ||
| /// </returns> | ||
| /// <remarks> | ||
| /// Refresh tokens are long-lived credentials. Store them securely and never expose them to end users or untrusted code. | ||
| /// </remarks> | ||
| public static string GetRefreshToken(this AuthenticationResult result) | ||
|
Robbie-Microsoft marked this conversation as resolved.
|
||
| { | ||
| return result?.RefreshToken; | ||
| } | ||
|
Robbie-Microsoft marked this conversation as resolved.
Robbie-Microsoft marked this conversation as resolved.
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.