Repository navigation
feat(msal): platform-correct sign-in, storage defaults and sign-out, tested against a stub tenant - #3161
Merged
Conversation
4 of 7 tasks
kazo0
force-pushed
the
msal-2-runtime-dispatch
branch
from
August 25, 2026 01:17
321e95e to
cd93b02
Compare
kazo0
force-pushed
the
msal-2-runtime-dispatch
branch
from
August 25, 2026 01:25
cd93b02 to
6bd8024
Compare
kazo0
force-pushed
the
msal-2-runtime-dispatch
branch
2 times, most recently
from
August 25, 2026 15:37
648fbd8 to
b254a52
Compare
kazo0
force-pushed
the
msal-2-runtime-dispatch
branch
from
August 25, 2026 15:38
b254a52 to
b21e80e
Compare
rajamatt
approved these changes
Aug 25, 2026
ajpinedam
approved these changes
Aug 25, 2026
…tested against a stub tenant Layer 2/4 of the MSAL authentication work (#3139): the provider fixes and the unattended test harness. No WebAssembly token-cache persistence yet - that is the next layer. - Platform selection is runtime dispatch (OperatingSystem.Is*), not #if: on Skia Android/iOS heads Uno.Sdk substitutes the plain netX.0 build of this assembly, and that build was a stub, so AddMsal registered nothing and every auth call failed with "No providers specified". UNO_EXT_MSAL is now defined for every platform that ships a functional provider (Package.targets applies the same rule in consuming projects); only Mac Catalyst keeps a stub, and AddMsal throws PlatformNotSupportedException there instead of failing later - Redirect URIs are derived per platform - msal{ClientId}://auth on Android, msauth.{BundleId}://auth on iOS, the WebAuthenticationBroker URI on WebAssembly, WithDefaultRedirectUri() on desktop - with the documented precedence: platform default < configuration < the app's Builder callback, which now runs after WithUnoHelpers() so it wins everywhere - Token-cache persistence is platform-aware: MsalStorageDefaults supplies the keychain (macOS) and keyring (Linux) properties MsalCacheHelper needs, so it no longer throws ArgumentNullException there (#3025); mobile lets MSAL persist natively; an opt-in AllowUnprotectedTokenCacheFallback keeps sign-in state on a machine with no secure store. Microsoft.Identity.Client moves to 4.87.0 for macOS desktop under .NET 10 (4.72.1's IsMac() did not recognise the marketing-string OS description) - Sign-out removes every account, not just the first; a refresh that cannot renew the session returns no tokens (the service signs out), while a transient failure keeps them; the 5-minute interactive timeout defaults only on desktop; MSAL exceptions are rethrown untouched; IMsalAuthenticationBuilder gains InteractiveBuilder(...) for the per-request modifiers - The vendored Microsoft.Identity.Client.Extensions.Msal *.wasm.cs stubs were dead code and are gone Tests: Uno.Extensions.Authentication.MSAL.Tests (unit, linked sources) covers redirect derivation and precedence and the storage defaults; Uno.Extensions.Authentication.MSAL.UI.Tests drives login, silent refresh, rejected and transient refreshes, sign-out and cancellation through real MSAL against StubEntra (a stubbed tenant at the HTTP layer) and StubWebUi, with no network and no human. The device lanes now run that namespace too. TestHarness drops its hard-coded uno-extensions://auth redirect, which the provider used to override on WebAssembly and now would not. Docs: redirect URIs, the Android/iOS callback plumbing, InteractiveBuilder, the interactive timeout and the storage options in the how-to; the behavior changes in UpdatingExtensions.md. Specs 009 and 010 carry the design trail. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EqfQh5ovrPEvFGcERLiLhH
MSAL keeps its token cache in the iOS keychain under com.microsoft.adalcache, and iOS only grants an app the groups its entitlements name. The single-project template ships Platforms/iOS/Entitlements.plist with an empty dict, so the first token save after a successful sign-in fails with missing_entitlements (or, on some MSAL versions, cannot_access_publisher_keychain while the PCA is built). Nothing in the how-to said so: the iOS section stopped at the callback scheme, and the platform table's "handled natively by MSAL" reads as nothing-to-do. Step 5 now covers iOS platform setup rather than the callback alone, with the two-entry array (bundle group first, so it stays the default access group for items written without one), the errors it fixes, the provisioning-profile difference between development and distribution, and the Builder(...) callback as the only way to change the group - there is no configuration key, since the Msal section binds to PublicClientApplicationOptions. The storage entitlements how-to prescribed only the bundle group, which does not satisfy MSAL; it now points here, and notes that single-project apps do not need the manual CodesignEntitlements property. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y2fPT3jMCkGrVjMv3zmqb3
kazo0
force-pushed
the
msal-2-runtime-dispatch
branch
from
August 25, 2026 16:37
b21e80e to
19872e9
Compare
…ubs in the builder Review follow-ups on #3161. - MsalStorageDefaults.ApplyDefaults took (isMacOS, isLinux); both could be true by mistake and macOS silently won. MsalSecureStore { None, MacKeychain, LinuxKeyring } makes the choice one value, and ForCurrentOS() is the only place that maps OperatingSystem.Is*() to it - Builder, InteractiveBuilder, Storage and Scopes kept a `#if !UNO_EXT_MSAL return builder;` stub. That build only exists for Mac Catalyst, where AddMsal throws PlatformNotSupportedException before the configure callback can run, so the stubs were unreachable; the real bodies compile on every TFM, so the branches are gone rather than made to throw Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EqfQh5ovrPEvFGcERLiLhH
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.
GitHub Issue (If applicable): closes #3157 (layer 2/4 of #3155; relates to #3025, #2438, #2346)
Stack 2/4 — base:
msal-1-ci-lanes. Review only this layer's diff. Depends on layer 1 for the device lanes that run its tests. Deliberately deferred upward: WebAssembly token-cache persistence (layer 3) and the Uno version floor (layer 4).PR Type
What is the current behavior?
AddMsalregisters nothing. Uno.Sdk substitutes the plainnetX.0build of the provider on those heads, and that build was a stub (UNO_EXT_MSALundefined), so every auth call fails with "No providers specified". The consumer-sidePackage.targetsgated the define on repo-internal properties that are empty in apps, so apps got the define on every TFM including the stubbed ones.AddMsalreturns silently and fails the same way, much later.#if ANDROID / #elif IOS / #elseblock to sign in.MsalCacheHelper.CreateAsyncthrowsArgumentNullException(MsalAuthenticationProvider does not work on MacOS out of the box #3025):SetupStoragesupplies no keychain/keyring properties. Caught, logged, no fallback.LoginAsyncre-wraps MSAL exceptions and loses the type; the per-request interactive modifiers (WithPrompt,WithLoginHint,WithCustomWebUi, …) are unreachable from the public surface. And none of it has a test.What is the new behavior?
Platform selection is runtime dispatch (
OperatingSystem.Is*, withIsMacCatalyst()excluded from the iOS path), so the substituted plain-TFM assembly behaves correctly on Skia mobile.UNO_EXT_MSALis defined for every platform that ships a functional provider andPackage.targetsapplies the same allow-list in consuming projects. Mac Catalyst throwsPlatformNotSupportedExceptionat registration.Redirect URIs are derived per platform —
msal{ClientId}://auth,msauth.{BundleId}://auth, theWebAuthenticationBrokerURI,WithDefaultRedirectUri()— with documented precedence: platform default < configuration < the app'sBuilder(...)callback, which now runs afterWithUnoHelpers()so it wins everywhere (it used to be overwritten on WebAssembly).UseDefaultPlatformRedirectUri = falseopts out.Token-cache persistence is platform-aware:
MsalStorageDefaultssupplies the keychain/keyring properties (configurable), mobile lets MSAL persist natively, and an opt-inAllowUnprotectedTokenCacheFallbackkeeps sign-in state on a machine with no secure store.Microsoft.Identity.Clientmoves to 4.87.0 for macOS desktop under .NET 10.Lifecycle: sign-out removes every account; a refresh that cannot renew the session returns no tokens (the service, from #3152, then signs out) while a transient failure keeps them; the 5-minute interactive timeout defaults only on desktop; MSAL exceptions are rethrown untouched. Additive API:
IMsalAuthenticationBuilder.InteractiveBuilder(...).Tests.
Uno.Extensions.Authentication.MSAL.Tests(unit, linked sources): redirect derivation and precedence, storage defaults.Uno.Extensions.Authentication.MSAL.UI.Tests:StubEntrafakes the tenant at the HTTP layer andStubWebUithe browser, so login → cache → silent refresh → rejected refresh → transient refresh → sign-out → cancellation all run through real MSAL (PKCE, code redemption, cache writes) with no network and no human. The device lanes now run this namespace. The vendoredMicrosoft.Identity.Client.Extensions.Msal/*.wasm.csstubs were dead code and are removed; TestHarness drops its hard-coded redirect that the provider now honours.Behaviour changes (documented in
UpdatingExtensions.md)Catalyst
AddMsalthrows; the app'sBuilder(...)wins over the platform default andWithUnoHelpers(); unrenewable refresh signs out; sign-out removes all accounts; exceptions untouched; desktop-only timeout default.PR Checklist
Other information
Verified locally: MSAL.Tests 27/27; package surface builds warning-free on all seven TFMs; desktop runtime suite 13 MSAL + 8 storage = 21/21. Every bug fix has a test that was red before it (recorded in
specs/012andspecs/010— 012 becausemaintook 009 for the hot-reload route refresh while this stack was open). Still open in spec 010: live on-device validation of the Skia-mobile fix — the runtime-test heads useProjectReference, so the SDK's substitution never fires in CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01EqfQh5ovrPEvFGcERLiLhH