Skip to content

feat(auth): fix the Oidc, Web and Custom providers and sign in on Skia Desktop - #3169

Open
kazo0 wants to merge 42 commits into
mainfrom
dev/sb/auth-providers-onmain
Open

kazo0 wants to merge 42 commits into
mainfrom
dev/sb/auth-providers-onmain

Conversation

@kazo0

@kazo0 kazo0 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #

Applies the classes of fix that landed for MSAL in #3160–#3163 to the three non-MSAL providers (Oidc, Web, Custom), and closes the Skia Desktop sign-in gap for Oidc and Web. Supersedes dev/sb/auth-providers-fixes (#3166 and #3167 are included); the history was rebuilt onto main rather than rebased because main had already absorbed the first ~70 commits of that branch through the split PRs — see specs/017-auth-providers-fixes/progress.md for the boundary and the six conflict resolutions.

Living specs: specs/017-auth-providers-fixes (F1–F12 with per-item verification), 014-http-client-lifetime, 015-web-redirect-defaults, 016-msal-cache-persistence-check.

PR Type

  • Bugfix
  • Feature
  • Build or CI related changes
  • Documentation content changes

What is the current behavior?

Oidc

  • A silent refresh that the token endpoint rejects is reported as success: result.IsError is never checked, the stale local token is tested instead of the result, and a null access token is stored. The user looks signed in with a dead token (F1).
  • Logout ignores LogoutResult.IsError and the cancellation token; the local cache is flushed even when the end-session round trip failed (F2).
  • WebAuthenticatorBrowser converts OperationCanceledException into UnknownError, so a caller-cancelled login surfaces as "login failed" (F3).
  • End-session requests are sent without id_token_hint, which providers that require it reject.

Web

  • No cancellation or timeout reaches the interactive surface on either broker path (F4).
  • A cancelled re-login returns an empty dictionary, and TokenCache.SaveAsync clears before writing — cancelling destroys the tokens the user still had (F5).
  • Logout ignores the broker result (F6).
  • PrefersEphemeralWebBrowserSession is applied through a compile-time #if that is unreachable on Skia iOS heads, where Uno's runtime-asset selector loads the plain-TFM build (F7, same mechanism as spec 010).
  • When no callback URI can be found, the warning names only two of the three sources tried and the broker's reason is logged at Debug (fix(web): name every callback source when a flow cannot start #3167).

Platform gap. Oidc and Web cannot sign in at all on Skia Desktop: WebAuthenticationBroker has no desktop implementation, so the interactive step throws (F8).

Elsewhere

  • AddClient always registers the typed client as transient (AddHttpClient<T> semantics), with no way to choose another lifetime — a client that must carry flow state across resolutions (e.g. a PKCE verifier between the authorization request and the code exchange) has to hand-roll its own registration.
  • MSAL re-probes the platform secure store on every launch; on macOS that probe is a keychain entry whose service name is randomised, so the OS prompts on every run and "Always Allow" never sticks (fix(msal): stop re-probing the secure store on every launch #3166).
  • TokenCache writes access and refresh tokens to whatever the default IKeyValueStorage is with no diagnostic when that store is unencrypted (Skia desktop on Windows/Linux, Skia-renderer Android/iOS, WebAssembly). The MSAL provider already warns in the same situation.
  • HowTo-MsalAuthentication.md lists Android's MSAL cache as "✅ Handled natively by MSAL". It is a plain SharedPreferences file — verified against Microsoft.Identity.Client 4.87.0's net8.0-android assets, which contain no encryption primitives.
  • The Oidc and Web runtime-test suites do not exist, so none of the above was covered.

What is the new behavior?

Oidc — refresh fails when the endpoint rejects it; logout honors the result and the token; cancellation propagates through WebAuthenticatorBrowser (and its CTSes are disposed); the cached id_token is passed as the end-session hint.

Web — the caller's CancellationToken reaches both broker paths (WinUIEx ct overload; .AsTask(ct)); ResponseStatus.UserCancel surfaces as OperationCanceledException before any save and ErrorHttp returns null, so a cancelled login leaves the previous session intact; logout honors the broker result; the ephemeral-session setting is applied via runtime dispatch with reflection on the substituted build; the "cannot start" warning names all three callback sources and the broker's reason.

Skia Desktop sign-in (new) — DesktopWebAuthenticationBrokerProvider in Uno.Extensions.Authentication.WinUI: a loopback HttpListener plus the system browser, loopback-only validation, one-shot accept, static completion page, honors the WinRTFeatureConfiguration.WebAuthenticationBroker timeout/defaults, and relays URL fragments (implicit-flow responses) back to the app. Registered from AddWeb/AddOidc behind a runtime desktop-OS allow-list so it is never selected on a Skia mobile head.

Web callback defaults — LoginCallbackUri/LogoutCallbackUri default to the broker's GetCurrentApplicationCallbackUri() when not configured, and {RedirectUri} in a start URI is replaced with the effective callback (spec 015).

Http — AddClient takes a ServiceLifetime for the typed client (spec 014).

MSAL — the persistence check runs once per cache rather than once per launch, a silently-rejected write is detected and reported, and "VerifyCachePersistence": "Always" restores the old behavior (spec 016).

Diagnostics — TokenCache logs a Warning naming the store when IsEncrypted is false, mirroring the MSAL provider.

Docs — platform-support matrices for Web and Oidc (HowTo-WebAuthentication.md, HowTo-OidcAuthentication.md), the Skia Desktop loopback registration, the packaged-only WinAppSDK note, the 7.0 behavior changes in UpdatingExtensions.md, and the corrected Android row plus an android:allowBackup="false" hardening note in HowTo-MsalAuthentication.md.

CI — RuntimeTestsFilter widened to 'Storage.UI.Tests | Uno.Extensions.Authentication.' on every runtime-test lane, so the Oidc/Web suites run on desktop, WebAssembly, Android and iOS.

Tests added — Uno.Extensions.Authentication.Oidc.UI.Tests (StubOidcServer + StubBrowser), Uno.Extensions.Authentication.UI.Tests (StubWebAuthenticationBroker + the desktop broker suite), Uno.Extensions.Authentication.Tests (Custom provider through the hosting API, token-logging guards, the unencrypted-store warning), Uno.Extensions.Http.Tests lifetime cases. Every bug fix above was red/fix/green with the failing test committed alongside.

Verification

Run on Windows against the final tip:

Check Result
Uno.Extensions-packageonly.slnf Release (MSBuild) 0 errors, no new warnings
Unit tests, the same filter package CI uses 1613 passed, 0 failed (19 pre-existing Reactive skips; one Reactive timing flake passed on re-run)
Runtime tests, Skia desktop head, the exact CI filter 57/57 passed (9 added by the review-panel commit)
cspell + markdownlint, the docs-validation lane's commands clean

Review panel. A seven-lens review (architect, security, skeptic, quality, operability, contract, performance) ran on the branch and returned fix-first; 3b1e8a87e fix(auth): address the review panel findings on PR #3169 addresses every finding but four small follow-ups, itemized in specs/017-auth-providers-fixes/progress.md under "Review panel (2026-08-27)". Headlines: an Oidc cancelled sign-in wiped the session and an offline refresh signed the user out (both red/fix/green now); the desktop-broker suite would have thrown on the WASM lane (__WASM__ is not defined by Uno.Sdk); a {State} placeholder binds Web responses to the request, since the loopback callback is reachable by any browser page; MSAL's persistence watchdog checks readability and retries once; the desktop broker logs.

Now verified: the Android emulator, iOS simulator and WebAssembly lanes executed the Oidc/Web suites for the first time on this PR and came back green (Azure build 230485 onward). The desktop broker's registration path without the test stub was validated on a Skia Desktop sample app (recorded in spec 017's review log).

Known and documented, not fixed here: Duende OidcClient 6 needs either an IIdentityTokenValidator or Policy.RequireIdentityTokenSignature = false, and AddOidc configures neither — pre-existing on main, documented in HowTo-OidcAuthentication.md.

PR Checklist

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Behavior changes that are additive but visible (all listed in UpdatingExtensions.md): a cancelled Web login now throws OperationCanceledException instead of returning false; Oidc refresh now returns false on an endpoint error; the Web callback URIs have a broker-derived default; MSAL's persistence probe no longer runs on every launch.

Other information

A macOS keychain-backed IKeyValueStorage was developed alongside this work and deliberately split out (dev/sb/macos-keychain-storage, spec 018): it would make an as-yet-unexecuted SecKeychain* P/Invoke the default store for every Skia macOS app, and belongs in its own PR after a first run on a real Mac.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 230470 has failed on uno.extensions.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 230474 has failed on uno.extensions.

kazo0 added a commit that referenced this pull request Aug 27, 2026
A seven-lens review returned fix-first. Everything it raised except four
small follow-ups (listed in specs/013 progress.md) lands here.

Same defect class the PR claims to fix, on paths the suites did not cover:
- Oidc: a cancelled sign-in wiped the previous session. The IBrowser
  adapter now maps the broker status to BrowserResultType (UserCancel with
  a null error, Timeout via the broker's error detail, HttpError otherwise)
  and the provider throws OperationCanceledException on UserCancel, like
  Web and MSAL. Red/fix/green: When_LoginCancelled_Then_PreviousSessionSurvives
- Oidc: any refresh error - including the token endpoint being unreachable
  - signed the user out. Only RFC 6749 token-endpoint error codes end the
  session; transport errors keep the tokens with a Warning, the MSAL
  provider's rule. Red/fix/green: When_RefreshFailsOffline_Then_SessionKept

Would have failed the first WASM lane run:
- __WASM__ is not defined by Uno.Sdk, so the desktop-broker suite compiled
  into the browser head; the test csproj now defines it for browserwasm

Web provider:
- {State} placeholder: a fresh 128-bit state per sign-in, and a response
  whose state does not match is rejected. The loopback callback is
  reachable by any page in the system browser, so without it a foreign
  navigation could hand the app a token (spec 015)
- timeout and cancel are told apart (broker error detail 408), logged at
  Information, and worded in the exception; logout cancel is Information
- callback resolution deduplicated into ExtractRedirectUri/ResolveCallbackUri
- response data matched to the callback as URIs, not an ordinal prefix
- a trimmed PrefersEphemeralWebBrowserSession setter logs Warning

Desktop broker:
- logs: Error on bind failure naming the prefix, Warning on timeout naming
  the callback, Debug on stray requests and dropped connections
- the result is built before the completion page is written, so a dropped
  connection cannot discard a completed sign-in; a failed relay write keeps
  listening
- response_mode=form_post read from the POST body; a callback with its own
  query still relays fragments
- non-http(s) request URIs rejected before anything is launched
- abandoned GetContextAsync observed, ConfigureAwait(false), Process handle
  disposed, relay-page markers interpolated from the parser's constants
- TryRegister returns bool; AddWeb/AddOidc document the first-wins ordering

MSAL persistence watchdog (spec 016):
- when the probe is skipped, the first cache read runs during setup so a
  store that became unreadable takes the existing fallback path instead of
  throwing out of a startup RefreshAsync
- the re-setup after a swallowed write is bounded to one per process
- MsalCacheHelper's own trace is forwarded into the logger, so the keychain
  or keyring cause appears next to the watchdog's error

Also: TokenCache does not warn for the in-memory store; the single-generic
AddClient lifetime overload rejects interfaces at registration and shares
the typed-factory lambda; stale spec-number breadcrumbs corrected; the
nested FakeKeyValueStorage removed; token-leak assertions and a Web
Refresh case added; CapturingLoggerProvider linked into the Oidc suite;
docs and upgrade notes updated for all of the above.

Verified: packageonly Release build clean; 1613 unit tests pass (one
Reactive timing flake passed on re-run); 57/57 runtime tests on the Skia
desktop head with the CI filter (9 new); cspell + markdownlint clean;
127.0.0.1 binds without elevation on Windows (checked with a scratch
HttpListener).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
kazo0 added a commit that referenced this pull request Aug 27, 2026
- dispose the port-probe TcpListener with a using declaration
- keep the broad catch in TryGetBrokerCallbackUri, but filter out
  OperationCanceledException and say why it is broad: what the broker
  throws when it has no callback is platform-specific, and the handler
  swallows nothing - the message becomes the Warning's stated reason
- the form_post test owns its FormUrlEncodedContent at method scope;
  the bot's suggested using inside the OnLaunch lambda would dispose the
  body while the POST is still in flight
- lessons.md: a desktop-only runtime-test build re-restores the shared
  projects' assets files, so the package build needs Restore,Build after it

Verified: packageonly Release build (Restore,Build) clean; 57/57 runtime
tests on the Skia desktop head with the CI filter.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
@kazo0

kazo0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Status on the build notices above:

  • 230470 / 230474 failed on the WebAssembly runtime-test lane: the desktop-broker suite gated on __WASM__, which Uno.Sdk no longer defines, so it compiled into the browser head and HttpListener threw. Fixed in e607a6d (the test csproj now defines the symbol for browserwasm, as RuntimeTests.Core does).
  • 230485 (e607a6d): every Azure lane green, including the first runs of the Oidc/Web suites on the Android emulator, iOS simulator and WebAssembly.
  • The remaining red check, Azure Static Web Apps CI/CD, fails with "This Static Web App already has the maximum number of staging environments" — a quota on PR preview environments (it fails on other PR branches too). Needs someone with portal access to delete stale staging environments; nothing in this branch affects it.
  • b5563ca addresses the three code-quality comments (two applied, one adapted — see the inline replies).

@kazo0

kazo0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

CI on b5563ca (build 230609): everything green except Hot-Reload Tests – Skia Desktop, which failed on its results-publish step with Too Many Requests (Azure DevOps throttling — no test failures recorded). Because that job failed, the Runtime Tests – Devices stage was skipped on this commit; it ran fully green on e607a6d, and this commit changes nothing those lanes execute (a using on the port probe, a catch filter, a test-only disposal, and lessons.md). "Rerun failed jobs" on 230609 should clear it.

@kazo0
kazo0 enabled auto-merge August 27, 2026 18:41
kazo0 and others added 21 commits September 11, 2026 15:13
- InternalRefreshAsync ignored RefreshTokenResult.IsError and cached the
  null access token from the failed response, leaving the user looking
  authenticated with a dead token (spec 012 F1; the OIDC mirror of
  b3a3e30)
- plumb the CancellationToken into RefreshTokenAsync
- new Uno.Extensions.Authentication.Oidc.UI.Tests suite (StubOidcServer +
  StubBrowser: no network, no discovery, no browser window) covering
  login, refresh renewal and the failing-refresh repro; wired into the
  runtime-test head

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- InternalLogoutAsync ignored LogoutResult.IsError and returned true
  unconditionally, so a cancelled or failed end-session flow still
  flushed the local token cache and reported success (spec 012 F2);
  the CancellationToken now reaches LogoutAsync too
- WebAuthenticatorBrowser swallowed OperationCanceledException into
  UnknownError, so a caller-cancelled sign-in surfaced as a failed
  login instead of cancelling; its timeout now reports
  BrowserResultType.Timeout, and both CancellationTokenSources are
  disposed (spec 012 F3)
- red/fix/green tests in Uno.Extensions.Authentication.Oidc.UI.Tests

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
…-in/out

- a cancelled interactive login returned an empty (non-null) token
  dictionary, which TokenCache.SaveAsync turns into a wipe of the
  previously cached session; UserCancel now surfaces as
  OperationCanceledException before any save, matching the MSAL
  provider's contract (spec 012 F5)
- logout discarded the broker result and returned true unconditionally,
  flushing the cache after a cancelled or failed end-session flow; any
  non-Success status now reports failure and keeps the session
  (spec 012 F6)
- no CancellationToken reached the interactive surface on either path;
  it is now checked before the UI opens and passed to the broker task
  and the WinUIEx ct overload (spec 012 F4)
- new Uno.Extensions.Authentication.UI.Tests suite: stub
  IWebAuthenticationBrokerProvider via ApiExtensibility (also what the
  Skia Desktop lane needs, where the built-in broker throws), 6 tests
  covering login, logout, cancel and failure paths; wired into the
  runtime-test head; full auth filter on the desktop head: 35/35

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- the setting was applied under #if __IOS__, which is compiled out of
  the plain-TFM build that Uno's runtime-asset selector substitutes
  onto Skia iOS heads (spec 010's mechanism), silently dropping
  PrefersEphemeralWebBrowserSession there (spec 012 F7)
- the plain build now sets it by reflection when actually running on
  iOS: the property is public stable API but exists only in the Apple
  flavors of Uno.dll, so the substituted build cannot reference it at
  compile time
- not exercisable by this repo's CI lanes (project references are never
  substituted) - see the exceptions note in specs/012 progress; all-TFM
  Release compile and the desktop-head Web suite (6/6) verified

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- new plain net9.0 Uno.Extensions.Authentication.Tests project: login,
  refresh, logout and cancellation through UseAuthentication/AddCustom
  in a bare host with a hand-rolled IKeyValueStorage fake (spec 012,
  item 13); 6/6 green via dotnet test
- added to the solution and to Uno.Extensions-packageonly.slnf so the
  package CI lane builds and discovers it

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- widen RuntimeTestsFilter from the MSAL namespace to all
  Uno.Extensions.Authentication suites (35 tests, verified green on
  the desktop head)
- extend the wasm lane's narrower filter with the OIDC and Web suites,
  which stub their transport/broker in-process and need no network;
  the MSAL subset stays excluded there until StubEntra reaches the
  browser
- document the engine's filter syntax hazard: '|'/';' are OR but the
  parser drops the character before an operator, so the spaces in
  'A | B' are load-bearing (verified against UnitTestFilter.cs and
  empirically: 20 tests, 0 failures with the exact wasm string)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
…roker

- Uno has no WebAuthenticationBroker on Skia Desktop (the skia flavor
  throws NotImplementedException), so Oidc and Web sign-in crashed on
  net9.0-desktop (spec 012 F8)
- new public DesktopWebAuthenticationBrokerProvider: system browser +
  one-shot loopback HTTP listener per RFC 8252 §7.3; loopback-only
  callback validation, static completion page (no reflected content),
  ArgumentList-based browser launch, first-use port cached for the
  process so login and logout share a redirect; honors the broker
  feature configuration (timeout, DefaultReturnUri, DefaultCallbackPath)
- registered from AddWeb/AddOidc behind a runtime desktop-OS allow-list:
  the plain-TFM build is what Skia mobile heads load (spec 010), so the
  native mobile brokers must keep winning at runtime, not compile time
- 4 broker tests (round trip, stable callback, non-loopback rejection,
  cancellation) via an overridable browser-launch seam; desktop head
  suite 10/10; all-TFM Release compile clean

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- add the sign-in surface matrix to HowTo-WebAuthentication: per-target
  broker, the WinAppSDK packaged-only constraint, and the broker's
  AuthenticationTimeout/cancellation behavior
- document the new Skia Desktop loopback broker: loopback redirect
  registration, variable-port default, code-flow-only limitation, and
  DesktopWebAuthenticationBrokerProvider.TryRegister for direct broker
  consumers
- cross-link the matrix from HowTo-OidcAuthentication with the
  OIDC-specific notes

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- the OIDC suite runs before the Web suite in the combined lane and its
  AddOidc now performs the (first-wins) desktop broker registration
  while building its host, so the Web suite's stub registered too late
  and all Web tests drove a real loopback listener until timeout -
  7 failures that only reproduce under the combined CI filter
- a ModuleInitializer (justified CA2255 suppression) registers the stub
  when the test assembly loads, before any suite executes
- combined desktop run with the exact CI filter: 41/41 passed; lesson
  recorded in specs/lessons.md

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- the sample apps configure everything through AddWeb<TService>'s typed
  callbacks (PrepareLoginStartUri/PrepareLoginCallbackUri/PostLogin)
  with no static LoginStartUri; nothing exercised that shape in-lane
- the new test proves the login URI comes from the typed callback, the
  broker is invoked with it, and PostLogin's exchanged tokens are the
  ones cached (passed on first run - written while ruling the provider
  out for a sample-app bug)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- logout never sent id_token_hint, so the identity provider could not
  trust the post-logout redirect: it prompted for confirmation and
  never redirected back to the app - on desktop the loopback listener
  then waited out the 5-minute broker timeout with the UI stuck on a
  disabled button (spec 012 F11, found via the OidcSteve sample)
- red/fix/green: When_Logout_Then_EndSessionCarriesIdTokenHint; the
  full Oidc runtime suite is 7/7 on the desktop head

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- new AddClient/AddClientWithEndpoint overloads take a required
  ServiceLifetime parameter; the existing methods are untouched, since
  adding an optional parameter to a shipped method is binary-breaking
  for a public NuGet API (spec 013)
- Transient delegates to the existing behavior; Singleton/Scoped
  register the endpoint pipeline (base address, native handler,
  delegating handlers, configure) as a named client and build the
  instance through ITypedHttpClientFactory over
  IHttpClientFactory.CreateClient(name)
- the WithEndpoint overloads type their configure callback to TEndpoint
  (the lifetime-less three-generic's EndpointOptions-typed callback was
  the anomaly); XML docs call out the handler-rotation trade-off of
  non-transient clients
- motivating case: a stateful OAuth helper resolved separately by each
  AddWeb callback, which previously needed a hand-rolled singleton
  against the named pipeline
- new Uno.Extensions.Http.Tests (5 tests): transient default unchanged,
  singleton/scoped semantics, interface pair resolution, custom
  TEndpoint binding; wired into the solution and packageonly filter;
  Release build of the package is warning-free
- documented in doc/Learn/Http/HttpOverview.md
- self-contained commit, intended to be cherry-picked into its own PR

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- browsers never send URL fragments to servers, so implicit-flow
  responses (tokens on the fragment) could not complete on the Skia
  Desktop loopback broker - and those are the only response shape the
  basic AddWeb configuration can consume without app-side exchange code
  (spec 012 F12)
- a bare callback hit now serves a static relay page whose script
  re-requests the callback with the fragment as a marked query; the
  broker restores the original fragment shape in ResponseData, strips
  the no-fragment sentinel on genuinely bare redirects, and leaves
  query-carrying redirects (code flows) on the existing single-request
  path
- static relay content only - the fragment travels in the browser's own
  request and is never reflected into HTML
- red/fix/green in the desktop broker suite; Authentication.UI.Tests
  13/13 on the desktop head

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
…eholder

- AddWeb required a per-platform callback (config value or Prepare
  callbacks); MSAL derives its redirect per platform (PR #3139) and
  AddOidc has AutoRedirectUriFromWebAuthenticationBroker, but Web had
  no equivalent (spec 014)
- when no callback resolves from configuration, the provider now falls
  back to WebAuthenticationBroker.GetCurrentApplicationCallbackUri():
  the custom scheme on Android/iOS, the app origin on WebAssembly, the
  loopback listener on Skia Desktop; not on WinAppSDK, where the WinRT
  broker answers ms-app://, wrong for the WinUIEx protocol flow
- the literal {RedirectUri} token in LoginStartUri/LogoutStartUri is
  replaced at sign-in/out time with the URL-encoded effective callback,
  so one static configuration serves every platform; a
  redirect_uri={RedirectUri} pair is no longer mistaken for a value by
  the extract-callback-from-start-uri logic
- behavior change (documented): a configuration with no resolvable
  callback used to fail with a warning and now attempts the flow with
  the derived callback
- red/fix/green in the Web runtime suite (15/15); documented in
  HowTo-WebAuthentication

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- HowTo-WebAuthentication: full configuration-key reference (callback
  resolution order, token keys and defaults, logout chain, ephemeral
  session), the {RedirectUri} placeholder in the walkthrough, accurate
  refresh semantics, and the fragment-relay behavior replacing the
  stale 'implicit flows cannot work over a loopback redirect' claim -
  also corrected in DesktopWebAuthenticationBrokerProvider's XML docs
- HowTo-OidcAuthentication: sign-out behavior (id_token_hint,
  cancelled sign-out keeps the session, local-only sign-out via
  ITokenCache), silent-refresh semantics, and the OidcClient id_token
  validation requirement
- AuthenticationOverview: Skia Desktop loopback broker note with a
  cross-link to the platform matrix
- UpdatingExtensions: 'Web and OIDC Authentication behavior changes'
  section for 7.0 upgraders, listing every deliberate behavior change
  from specs 012 and 014 with links

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
- the PR description promised UpdatingExtensions.md would carry the
  deliberate behavior changes with migration guidance; this adds the
  section: the Uno 6.8 floor and why, per-platform redirect derivation,
  Builder(...) precedence, Catalyst throwing at registration, the
  persisted WebAssembly token cache and its BrowserCacheLocation knob,
  unrenewable-refresh sign-out, full-account sign-out, untouched MSAL
  exceptions, and the interactive timeout

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FbxVQgeqVf8bJT2wHUS8TV
MsalCacheHelper.VerifyPersistence() ran on every storage setup, costing a
write, a read and a delete against the platform's secure store per app start.

On macOS it could never be granted once and for all. MSAL's validation
accessor builds its probe entry with a fresh Guid in the keychain service
name:

    // MacKeychainAccessor.CreateForPersistenceValidation()
    new MacKeychainAccessor(_cacheFilePath + ".test",
                            _service + Guid.NewGuid(), _account, _logger)

macOS gates keychain access with a per-item ACL, so an entry that never has
the same name twice is a first-ever access every time: the user is prompted,
answers "Always Allow", the entry is deleted at the end of the check, and the
next launch asks again. Three prompts on every start, with no way to make
them stop.

The call could not simply be dropped. It was the only thing reporting a
broken store, because MsalCacheHelper handles the two directions
differently: Storage.ReadData() rethrows, but AfterAccessNotification catches
and logs "Could not write the token cache. Ignoring." Removing the check
would have traded a startup error for silent loss of the refresh token.

Two properties of the accessors make a cheaper equivalent possible. Every
ICacheAccessor.Write ends in FileIOWithRetries.TouchFile(_cacheFilePath), so
the cache file tracks whether a write landed - on macOS too, where the
payload lives in the keychain. And TokenCache.OnAfterAccessAsync invokes the
synchronous callback and then the asynchronous one, so the provider can
attach SetAfterAccessAsync without displacing RegisterCache.

So:

- MsalConfiguration.VerifyCachePersistence (Auto default, Always, Never),
  with the decision in MsalStorageDefaults.ShouldVerifyPersistence as a pure
  function; the provider supplies cacheAlreadyPersisted from File.Exists.
- ArmWriteVerification / OnAfterCacheAccessAsync confirm the first
  state-changing write reached the store and, when it did not, log and reset
  _setupStorageTask so the next setup rebuilds - probing even under Auto,
  since the file is missing, and taking the
  AllowUnprotectedTokenCacheFallback path if the store is genuinely broken.
- The unprotected-file fallback still verifies unconditionally: it only runs
  because the protected store already failed, and a plain file carries none
  of the cost that justifies skipping.

Steady-state macOS launches now make zero extra secure-store round-trips.
Verified on the net10.0-desktop head of Authentication.MsalExtensionsDemo:
three keychain prompts at startup before, none after, with the keychain
item's mdat still advancing so the cache is demonstrably read and written.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01RhtkcHHpbm6XiDagFY6VaS
When neither configuration nor the start URI nor the platform broker yields
a callback URI, sign-in and sign-out cannot start. The warning named only
the first two sources:

    LoginCallbackUri not specified and redirect_uri not set in LoginStartUri

which reads as a configuration slip even when the start URI does carry
{RedirectUri} and the real cause is a platform with no callback to derive.
The broker's own failure message was logged at Debug - invisible at the
level an app actually runs with - so the one line explaining the dead end
never appeared.

Found the hard way on an iOS head whose Info.plist declared
CFBundleURLSchemes at the root instead of inside CFBundleURLTypes, so iOS
ignored the scheme entirely. The app reported "redirect_uri not set", which
is the one thing that was not wrong.

GetBrokerCallbackUri becomes TryGetBrokerCallbackUri, returning the broker's
message alongside the (null) URI rather than logging it at Debug and
dropping it. The caller folds it into a single Warning that names all three
sources tried and says what makes a broker-derived callback possible - a
custom scheme registered for the app, CFBundleURLTypes/CFBundleURLSchemes in
Info.plist on iOS and Mac Catalyst, an intent filter on Android. The reason
travels to the caller rather than being logged at the source because that is
the last source tried: reported there, it is visible at Warning level, where
the flow being over makes it worth saying.

Both the login and logout paths take the same treatment.

Guarded by Given_WebAuthentication.When_BrokerCannotDeriveCallback_Then_
WarningNamesBroker, with StubWebAuthenticationBroker gaining a
CallbackUriError that makes GetCurrentApplicationCallbackUri throw the way a
real broker does on a platform with no callback. The test asserts the flow
does not start, the broker UI never opens, and the warning carries both the
broker's name and its reason.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01RhtkcHHpbm6XiDagFY6VaS
kazo0 and others added 13 commits September 11, 2026 15:14
The branch numbered these while its own MSAL work was 009-011; those became
010-012 when they were split into main, so 012 was taken.

- 012-auth-providers-fixes -> 013
- 013-http-client-lifetime -> 014
- 014-web-redirect-defaults -> 015
- 015-msal-cache-persistence-check -> 016

Includes the ~30 "spec NNN" references in source comments and specs/lessons.md.
specs/009-hot-testing-reactive-feed-mocks is deliberately untouched: its "spec
013" means a planned MVUX generation spec, not http-client-lifetime.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QgRrieijt7SHnMLzCM9QAh
Rebuilding the branch on main left the project registered twice - main's
auth-core-fixes added it, and the cherry-picked Custom-provider commit added it
again under its own GUID. MSBuild refuses the whole solution for it:
"MSB5004: The solution file has two projects named
Uno.Extensions.Authentication.Tests".

Keeps main's GUID and de-duplicates the packageonly filter's project list.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QgRrieijt7SHnMLzCM9QAh
- specs/013: how the branch was rebuilt (net diff, not a 90-commit rebase), the
  six real conflicts and which side won each, and the verification numbers
- specs/017: the post-rebuild runtime-test result
- specs/lessons.md: git cherry reports "not upstream" for a commit main absorbed
  under a reworded or squashed message, so it cannot be used to find the boundary
  of a branch that has had PRs split out of it

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QgRrieijt7SHnMLzCM9QAh
main is clean on both linters; every failure below arrived with the
cherry-picked commits or the rebuild record, and the docs lane runs over
**/*.md with only samples/, src/ and testing/ ignored - so specs/ is linted.

- cspell: whitelist `ciphertext` and `PKCE`, both legitimate domain terms
- cspell: en-US spellings (`behaviour`, `recognised`, `normalising`), drop the
  coined `unioned`, and `pre-empting` - which cspell splits at the hyphen
- markdownlint MD032/MD022: blank lines around the review-log lists and around
  the process-global-registries lesson heading, lost when the lessons.md
  conflict markers were removed
- markdownlint MD029: a one-item ordered list starting at `3.` satisfies no
  MD029 style; the number indexes the implementation list, so it is now prose

Verified: cspell and markdownlint clean over all 244 markdown files, run with
the exact commands from stage-docs-validations.yml.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QgRrieijt7SHnMLzCM9QAh
Skia desktop on Windows/Linux, Skia-renderer Android/iOS and WebAssembly
fall back to a cleartext IKeyValueStorage, and TokenCache wrote access and
refresh tokens there silently. The MSAL provider already warns in the same
situation; mirror it so the app author can register a protected store.

- TokenCache logs a Warning naming the store when IsEncrypted is false
- Given_TokenLogging covers both the warning and its absence on an
  encrypted store; FakeKeyValueStorage gains an IsEncrypted init knob

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
…rences file

The platform table read "Handled natively by MSAL" with a tick, which reads
as secure. Verified against Microsoft.Identity.Client 4.87.0's
net8.0-android assets: the accessor writes SharedPreferences with no
encryption primitives at all, so the cache is sandbox-protected only.

- correct the Android row and name the iOS store explicitly
- add an android:allowBackup="false" hardening note to the Android setup
- mention the new unencrypted-store Warning from the token cache

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
- Web and OIDC pages now say where tokens are stored (the host's default
  IKeyValueStorage, per platform) and that an unencrypted store is reported
  by a startup Warning, linking to the storage overview's table
- OIDC on Skia Desktop: the provider does not derive the redirect URI by
  default there, so the bullet now names the two options - a fixed
  RedirectUri or AutoRedirectUriFromWebAuthenticationBroker()
- fix the method name on the OIDC page and walkthrough
  (AutoRedirectUriFromAuthenticationBroker never existed)
- Web platform matrix links the Android intent filter and the iOS
  CFBundleURLTypes setup, the malformed-plist cause behind #3167
- Skia Desktop: say how to pin the loopback port and name the
  DefaultCallbackPath / DefaultReturnUri knobs the broker honors
- upgrade notes: one bullet for the new unencrypted-store Warning

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
A seven-lens review returned fix-first. Everything it raised except four
small follow-ups (listed in specs/013 progress.md) lands here.

Same defect class the PR claims to fix, on paths the suites did not cover:
- Oidc: a cancelled sign-in wiped the previous session. The IBrowser
  adapter now maps the broker status to BrowserResultType (UserCancel with
  a null error, Timeout via the broker's error detail, HttpError otherwise)
  and the provider throws OperationCanceledException on UserCancel, like
  Web and MSAL. Red/fix/green: When_LoginCancelled_Then_PreviousSessionSurvives
- Oidc: any refresh error - including the token endpoint being unreachable
  - signed the user out. Only RFC 6749 token-endpoint error codes end the
  session; transport errors keep the tokens with a Warning, the MSAL
  provider's rule. Red/fix/green: When_RefreshFailsOffline_Then_SessionKept

Would have failed the first WASM lane run:
- __WASM__ is not defined by Uno.Sdk, so the desktop-broker suite compiled
  into the browser head; the test csproj now defines it for browserwasm

Web provider:
- {State} placeholder: a fresh 128-bit state per sign-in, and a response
  whose state does not match is rejected. The loopback callback is
  reachable by any page in the system browser, so without it a foreign
  navigation could hand the app a token (spec 015)
- timeout and cancel are told apart (broker error detail 408), logged at
  Information, and worded in the exception; logout cancel is Information
- callback resolution deduplicated into ExtractRedirectUri/ResolveCallbackUri
- response data matched to the callback as URIs, not an ordinal prefix
- a trimmed PrefersEphemeralWebBrowserSession setter logs Warning

Desktop broker:
- logs: Error on bind failure naming the prefix, Warning on timeout naming
  the callback, Debug on stray requests and dropped connections
- the result is built before the completion page is written, so a dropped
  connection cannot discard a completed sign-in; a failed relay write keeps
  listening
- response_mode=form_post read from the POST body; a callback with its own
  query still relays fragments
- non-http(s) request URIs rejected before anything is launched
- abandoned GetContextAsync observed, ConfigureAwait(false), Process handle
  disposed, relay-page markers interpolated from the parser's constants
- TryRegister returns bool; AddWeb/AddOidc document the first-wins ordering

MSAL persistence watchdog (spec 016):
- when the probe is skipped, the first cache read runs during setup so a
  store that became unreadable takes the existing fallback path instead of
  throwing out of a startup RefreshAsync
- the re-setup after a swallowed write is bounded to one per process
- MsalCacheHelper's own trace is forwarded into the logger, so the keychain
  or keyring cause appears next to the watchdog's error

Also: TokenCache does not warn for the in-memory store; the single-generic
AddClient lifetime overload rejects interfaces at registration and shares
the typed-factory lambda; stale spec-number breadcrumbs corrected; the
nested FakeKeyValueStorage removed; token-leak assertions and a Web
Refresh case added; CapturingLoggerProvider linked into the Oidc suite;
docs and upgrade notes updated for all of the above.

Verified: packageonly Release build clean; 1613 unit tests pass (one
Reactive timing flake passed on re-run); 57/57 runtime tests on the Skia
desktop head with the CI filter (9 new); cspell + markdownlint clean;
127.0.0.1 binds without elevation on Windows (checked with a scratch
HttpListener).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
- dispose the port-probe TcpListener with a using declaration
- keep the broad catch in TryGetBrokerCallbackUri, but filter out
  OperationCanceledException and say why it is broad: what the broker
  throws when it has no callback is platform-specific, and the handler
  swallows nothing - the message becomes the Warning's stated reason
- the form_post test owns its FormUrlEncodedContent at method scope;
  the bot's suggested using inside the OnLaunch lambda would dispose the
  body while the POST is still in flight
- lessons.md: a desktop-only runtime-test build re-restores the shared
  projects' assets files, so the package build needs Restore,Build after it

Verified: packageonly Release build (Restore,Build) clean; 57/57 runtime
tests on the Skia desktop head with the CI filter.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
Everything needed to resume in a fresh session, checked in rather than in
the untracked handoff: branch/PR state and the split-out keychain branch,
CI outcomes per build (230485 fully green, 230609's throttled hot-reload
upload and the skipped device stage, the SWA staging quota), what is left
on the PR, the ranked follow-up work including the token-storage hardening
plan, the cross-platform token-storage audit with its evidence, and the
verification loop that matches CI.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BqwJ47NVrvRR9Ghjc4Ti7X
`main` has taken 013 for `013-mvux-mocking-previews`, so the branch's
`013-auth-providers-fixes` collides with it after the rebase and both sides
carry "spec 013" comments in source.

- Move `specs/013-auth-providers-fixes` to `specs/017-auth-providers-fixes`.
- Carry the 24 branch-side "spec 013" references with it.
- Leave `specs/009-hot-testing-reactive-feed-mocks` alone: its "spec 013" means
  the planned MVUX generation spec, which is exactly what `main` just landed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HY4wJYs9suy6qQj5kBAAf2
`build/ci/.azure-pipelines.yml` is UTF-8-with-BOM on `main`; an edit on this
branch rewrote it without one, which shows up as a spurious whole-first-line
change on every diff against `main`. Only the `RuntimeTestsFilter` change
remains.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HY4wJYs9suy6qQj5kBAAf2
`MsalAuthenticationProvider.cs`, `MsalStorageDefaults.cs` and
`Uno.Extensions.Authentication.Tests.csproj` have no BOM on `main`; edits on
this branch rewrote them with one, which shows as a phantom first-line change
on every diff. Content is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HY4wJYs9suy6qQj5kBAAf2
@kazo0
kazo0 force-pushed the dev/sb/auth-providers-onmain branch from ecd32e8 to 0e2e0e8 Compare September 11, 2026 19:25
@kazo0

kazo0 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (b5de96b01) and force-pushed — the branch was 25 behind and the PR had gone CONFLICTING.

Conflicts: two, both in Uno.Extensions.sln, both add/add between main's new MVUX-mocking projects and this branch's auth test projects. Resolved as a union; the branch's own fix(build): drop the duplicated Authentication.Tests solution entry then re-applied against main's GUID. No duplicate project names remain (MSB5004 was the original reason that commit exists). The diff against the pre-rebase branch contains only main's new work — no auth content lost.

Three cleanups on the way:

  • specs/013-auth-providers-fixes → specs/017-auth-providers-fixes. main has taken 013 for 013-mvux-mocking-previews, and both sides carried spec 013 comments in source. The 24 branch-side references moved with it; specs/009-hot-testing-reactive-feed-mocks was deliberately left alone, since its "spec 013" meant the planned MVUX generation spec — which is exactly what main just landed.
  • BOM normalization. This branch had dropped the BOM on build/ci/.azure-pipelines.yml (which has one on main) and added one to three files that don't (MsalAuthenticationProvider.cs, MsalStorageDefaults.cs, Uno.Extensions.Authentication.Tests.csproj) — four phantom first-line diffs, now gone. No content change.
  • Extended the spec-renumber lesson in specs/lessons.md: the blanket replacement it warns about rewrote that very line before it was caught.

Verification, on the rebased tip:

Check Result
Uno.Extensions-packageonly.slnf Release, via MSBuild exit 0 — only NETSDK1202 (EOL android workload) and 3x CS1591 in WebAuthenticatorBrowser.cs, both pre-existing on main
Unit tests, the package-CI filter 1626 passed, 0 failed, 19 skipped (the known Reactive skips) — includes main's new Uno.HotTesting.Reactive.Tests
markdownlint + cspell on the touched markdown clean

Runtime tests were not re-run locally — nothing in the rebase touches UI or navigator behavior, and the device lanes ran fully green on the previous tip. CI on this push is the check.

The one thing still red that isn't in my hands: Azure Static Web Apps CI/CD, failing with "This Static Web App already has the maximum number of staging environments" — an Azure quota on PR preview environments that also fails other PR branches. Someone with portal access has to delete stale staging environments.

kazo0 and others added 8 commits September 11, 2026 15:27
- The two `Uno.Extensions.sln` add/add conflicts and how they were resolved,
  including the recurrence on the duplicate-entry commit.
- Why this spec moved from 013 to 017, and the two traps the renumber hit.
- The BOM cleanup in both directions.
- Verification on the rebased tip: Release build clean, 1626 unit tests green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HY4wJYs9suy6qQj5kBAAf2
- LoginAsync saved whatever the provider returned, and TokenCache.SaveAsync clears first - without raising Cleared, so no LoggedOut. A failed, rejected or cancelled re-login signed the user out silently.
- The service now saves nothing and returns false when a login yields no tokens, the rule RefreshAsync already applied.
- Red tests: When_LoginReturnsNoTokens_Then_PreviousSessionKept, When_LoginReturnsEmptyTokens_Then_PreviousSessionKept.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
… loopback callback

- A cancelled or timed-out sign-in returns no tokens instead of throwing OperationCanceledException; with the service fix the session survives, and LoginAsync is back to the false it returned before this branch.
- A sign-in on a loopback callback whose LoginStartUri has no {State} logs a Warning: any page in the system browser can reach that callback.
- Tests cover a failed re-login and a state mismatch on re-login keeping the previous session.
- The stub broker is public and can report an error detail, for the OIDC adapter tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
- form_post bodies are capped at 32 KB and read inside the keep-listening guard, so an oversized or aborted POST from any page no longer ends the flow.
- The completion page is written under its own budget; the flow timeout cannot discard a response that already arrived.
- A default port that fails to bind is forgotten, so the next flow probes again instead of failing until restart.
- A second concurrent flow throws InvalidOperationException rather than a bind error.
- The broker announces itself on its first flow, and LaunchBrowserAsync is documented as a supported extension point.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
- IsTokenEndpointError was an RFC 6749 allow-list, so interaction_required and its kind kept the session on a refused refresh token. Any OAuth-code-shaped error is a verdict now; temporarily_unavailable and server_error are not.
- A cancelled or failed sign-in returns no tokens; the session no longer depends on an IBrowser leaving Error null.
- WebAuthenticatorBrowser tells its own timeout from a flow that cancelled itself, and reports the exception message rather than a stack trace.
- Given_WebAuthenticatorBrowser drives the real adapter over the stub broker.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
- The watchdog's state lived on a record that is copied with 'with' while the callback stayed bound to the original; every copy now shares one MsalCacheWriteWatchdog.
- File.Exists could not fail under Auto, which skips the probe because the file exists; the check compares last-write times.
- A watchdog-requested setup forces the persistence probe and first detaches the previous MsalCacheHelper.
- VerifyReadableAsync no longer reclassifies MsalException as a persistence failure, which could move the cache to the plaintext fallback.
- Given_MsalCacheWriteWatchdog, 7 tests; spec 016 records the remaining testing exception.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
- Short names let two same-named client types share one HttpClient pipeline - base address, delegating handlers and authorization included.
- Transient on the single-generic lifetime overload delegates to the lifetime-less overload, so it accepts an interface as documented.
- Tests for the collision, the interface rejection, explicit Transient and the no-name path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
… under 7.4

- Web/OIDC behavior notes moved to the 7.4 section and updated for the revised login contract; the duplicate 7.0 MSAL list is gone.
- Spec 017 revises F5 and its progress file lists each panel finding, what was done, what was not, and the verification results.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_011HFyjwTxCPdJnGxQpSxEz3
[TestInitialize]
public void CreateFolder()
{
_folder = Path.Combine(Path.GetTempPath(), "uno-ext-msal-watchdog-" + Guid.NewGuid().ToString("N"));
{
_folder = Path.Combine(Path.GetTempPath(), "uno-ext-msal-watchdog-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(_folder);
_cacheFile = Path.Combine(_folder, "msal.cache");
{
// Forget a default port that would not bind, so the next flow probes for another rather
// than failing on this one until the app restarts. A pinned port is the app's to fix.
var wasDefault = Interlocked.CompareExchange(ref _defaultPort, 0, callbackUri.Port) == callbackUri.Port;
kazo0 added a commit that referenced this pull request Oct 26, 2026
…Broker for the Oidc and Web providers

Uno Platform has no WebAuthenticationBroker implementation on the Skia Desktop
target: the built-in provider throws NotImplementedException, so AddOidc and
AddWeb cannot complete an interactive sign-in there at all. This adds
DesktopWebAuthenticationBrokerProvider (system browser plus a loopback
HttpListener, loopback-only validation, one flow at a time, a static completion
page, fragment relay, the broker's AuthenticationTimeout reported as a cancel
with TimeoutErrorDetail) and registers it through Uno's ApiExtensibility
registry from AddOidc/AddWeb on Windows, macOS and Linux only; the native
brokers keep winning on Android, iOS, Mac Catalyst and WebAssembly, and an app
that registers its own provider first keeps it.

Extracted from #3169, which also changes the providers' refresh, cancellation
and logout behaviour; this lands the platform gap on its own so it can ship
first. The desktop broker runtime-test suite comes with it and is added to
the runtime-tests host and the CI filter.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
kazo0 added a commit that referenced this pull request Oct 26, 2026
- 020 is taken on main by the Uno.UI.Lottie reference
- Add spec.md with the broker's design; record the PR review in progress.md
- Point the id_token_hint note at #3169's own spec instead of main's 017

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015tKeWCuqJ7QVyKcChvivDX
@mergify

mergify Bot commented Nov 12, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

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.

2 participants