Repository navigation
feat(msal): cache the ID token so apps can read the user's claims (backport #3185) - #3188
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 (cherry picked from commit c8f3019)
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 (cherry picked from commit 4de349b)
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 (cherry picked from commit d31e118)
kazo0
enabled auto-merge
September 23, 2026 14:55
kazo0
approved these changes
Sep 23, 2026
This was referenced Sep 23, 2026
ushenkodmitry
pushed a commit
to ushenkodmitry/Uno.Samples
that referenced
this pull request
Nov 4, 2026
… sample Uno.Extensions 7.4.0-dev.54 is the first build whose MSAL provider caches the ID token next to the access token (unoplatform/uno.extensions#3188), which is the only place an app can read the signed-in user's claims. Pin it, and have the Sign in page's TOKEN card decode the ID token's payload so the claims (name, preferred_username, oid, tid, ...) are visible without leaving the app. - MsalFlowService.DescribeClaimsAsync reads IdTokenKey from ITokenCache and decodes the payload to indented JSON; the existing token summary already lists the new IdToken entry with its length - SignInViewModel.ClaimsSummary, hidden until a token is cached and scrubbed through SecretRedactor.ApplyToJson while recording - README: TOKEN card description and the "what the provider does" list Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_015CwhNQC1BFcQiymU9GvsP1
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.
This is an automatic backport of pull request #3185 done by [Mergify](https://mergify.com).