Repository navigation
feat(msal): cache the ID token so apps can read the user's claims - #3185
Merged
Merged
Conversation
The MSAL provider only copied the access token into the Uno token cache, so ITokenCache.TokenAsync(IdTokenKey) was always empty while the OIDC provider populates it. A B2C app had no way to read the user's claims (custom attributes, roles, user flow) for in-app authorization. - store AuthenticationResult.IdToken under TokenCacheExtensions.IdTokenKey - Given_MsalAuthentication.When_Login_Then_IdTokenCached (red before, green after) - assert the ID token survives a silent refresh - When_TokenResponseHasNoAccessToken_Then_NotAuthenticated pins the B2C openid-only case - token-leak guard now also asserts the ID token never reaches the logs - docs: B2C authority/scope/broker/redirect notes and a "Reading the user's claims" section Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FmSTEgLz4csBxzrsYe7p8G
Kunal22shah
approved these changes
Sep 17, 2026
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
TokenCache.SaveAsync wrote keys in dictionary order with no failure isolation. On packaged WinAppSDK (LocalSettings caps a value at 8 KB) a claim-heavy ID token threw after the access token was written, so LoginAsync / RefreshAsync threw while HasTokenAsync reported true. - write the ID token last and best-effort; log key + length, never the value - clear the in-memory remnant the caching stores write before the backing store - a rejected access token still throws - Given_TokenCache.When_IdTokenRejectedByStorage_Then_SessionKeptWithoutIt (red before, green after) - Given_TokenCache.When_AccessTokenRejectedByStorage_Then_SaveThrows Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AYYN6BiumAAF6B4H6WhW4H
With only openid / offline_access scopes B2C returns an ID token and a refresh token but no access token. The provider reported not signed in yet left MSAL's account and refresh token cached - cleartext localStorage on WebAssembly - logged nothing above Trace, and redeemed that refresh token silently on every later sign-in before prompting. - TokensOrSignOutAsync on login and refresh: Warning naming the scopes, then remove the MSAL accounts and serialized cache - RemoveAccountsAsync extracted from logout and shared - When_TokenResponseHasNoAccessToken_Then_NotAuthenticated asserts the warning, the removed cache entry and a single token request on the next sign-in (red before, green after on the desktop head) - docs: correct the B2C scope note and the packaged-Windows 8 KB note - specs/012: record both review-panel fixes and what is still open Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AYYN6BiumAAF6B4H6WhW4H
Contributor
Author
|
@Mergifyio backport servicing/7.4 |
✅ Backports have been createdDetails
|
kazo0
added a commit
that referenced
this pull request
Sep 23, 2026
…-3185 feat(msal): cache the ID token so apps can read the user's claims (backport #3185)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The MSAL provider only copied the access token into the Uno token cache, so ITokenCache.TokenAsync(IdTokenKey) was always empty while the OIDC provider populates it. A B2C app had no way to read the user's claims (custom attributes, roles, user flow) for in-app authorization.