Skip to content

feat(auth): sign in on Skia Desktop with a loopback WebAuthenticationBroker for the Oidc and Web providers (backport #3261) - #3264

Merged
kazo0 merged 9 commits into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3261
Oct 27, 2026
Merged

kazo0 merged 9 commits into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3261

Conversation

@mergify

@mergify mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown

GitHub Issue (If applicable): closes #

Extracted from #3169 so the platform gap can ship on its own. Two OIDC changes from #3169 landed here too, because desktop sign-in and sign-out needed them: cancellation propagation and id_token_hint (see "Every platform" below). #3169 keeps the rest (refresh verdicts, honoring LogoutResult.IsError, per-flow state in the Web provider, Web callback defaults) and rebases onto this.

PR Type

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

What is the current behavior?

Uno Platform has no WebAuthenticationBroker implementation on the Skia Desktop target (net10.0-desktop): WebAuthenticationBrokerProvider.skia.cs throws NotImplementedException, and no desktop runtime package registers a replacement. AddOidc() routes every interactive step through WebAuthenticatorBrowser → WebAuthenticationBroker, and AddWeb() uses the broker directly, so on Windows, macOS and Linux desktop both providers fail every sign-in: the provider logs Error logging in: System.NotImplementedException and LoginAsync returns false. MSAL is unaffected because MSAL.NET brings its own system browser and loopback listener.

Reproduced on Uno.Sdk 7.0.0-dev.77 / Uno.Extensions 8.0.0-dev.85 with the Uno.Samples OIDC extensions demo (unoplatform/Uno.Samples branch dev/sb/oidc-extensions-demo), which has to ship an app-side IBrowser to sign in on desktop at all.

What is the new behavior?

Skia Desktop

  • DesktopWebAuthenticationBrokerProvider (in Uno.Extensions.Authentication.WinUI): opens the request URI in the system browser and completes the flow from the first request to a loopback HttpListener bound to the callback URI. Loopback-only validation (URI and remote endpoint), one flow at a time (a second concurrent flow throws InvalidOperationException), form_post bodies capped at 32 KB, static no-store pages, relay of URL-fragment responses, and the broker's AuthenticationTimeout reported as UserCancel with ResponseErrorDetail = TimeoutErrorDetail (408). The result keeps the callback URI as the caller wrote it. LaunchBrowserAsync is protected virtual for apps that want another browser or a private window. A failed browser launch never logs the request URL.
  • AddOidc() and AddWeb() call DesktopWebAuthenticationBrokerProvider.TryRegister() off WinAppSDK. It registers the provider through ApiExtensibility.Register(typeof(IWebAuthenticationBrokerProvider), ...) only when the process runs on Windows, Linux or macOS; Android, iOS and the browser keep their native brokers (a runtime check, because the plain-TFM build of this assembly is what Skia mobile heads load). The registry is first-wins, so an app that registers its own provider before AddOidc/AddWeb keeps it, and apps that call WebAuthenticationBroker directly can call TryRegister() themselves. The outcome is logged through the host's logger once the host is built.
  • WebAuthenticationBroker.GetCurrentApplicationCallbackUri() on desktop returns http://localhost:{port}/authentication-callback with a port chosen once per process (free on IPv4 and IPv6 loopback, re-probed after a bind failure), or WinRTFeatureConfiguration.WebAuthenticationBroker.DefaultReturnUri when set. With AutoRedirectUri, the OIDC provider follows that port on every flow.

Every platform (OIDC provider)

  • WebAuthenticatorBrowser reports the broker's outcome as a BrowserResultType (Timeout for both the client's and the broker's timeout, UserCancel, HttpError) instead of a Success with no response or an UnknownError.
  • Behavior change: a CancellationToken cancelled during LoginAsync/LogoutAsync now propagates as OperationCanceledException out of IAuthenticationService. Before, a cancelled LoginAsync returned false and, because the failed result was saved as an empty token set, also cleared the stored tokens; now it throws and leaves them alone. A cancelled LogoutAsync still clears the tokens. This applies on WinAppSDK too, where the WinUIEx branch shares the same catches.
  • Sign-out sends the cached ID token as id_token_hint, which identity providers need before they redirect back to PostLogoutRedirectUri.

Tests and docs

  • Uno.Extensions.Authentication.WinUI.Tests (runtime tests, gated to the desktop head, referenced from the runtime-tests host and added to RuntimeTestsFilter): 34 tests. Given_DesktopWebAuthenticationBroker has 20 cases; the rest are in Given_DesktopWebAuthenticationBrokerRegistration, Given_WebAuthenticatorBrowser and Given_OidcAuthenticationProvider.
  • Docs: a Skia Desktop section in the Web and OIDC how-tos, and an 8.0 upgrade note covering the desktop broker and the OIDC changes, the behavior change included.
  • Spec: specs/021-desktop-web-auth-broker/ (spec.md + progress.md).

Verified locally on macOS (Skia desktop runtime-tests host, filter Authentication.UI.Tests): 34 passed, 0 failed. Uno.Extensions.Authentication.WinUI, Uno.Extensions.Authentication.Oidc.WinUI and the test project build in Release with only the CS1591 warnings already on main.

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)

Breaking changes: there are no binary or source breaks; the public surface is only additive. There is one runtime behavior change, described above: a cancelled LoginAsync now throws OperationCanceledException instead of returning false, and keeps the stored tokens. Apps that pass a cancellable token to LoginAsync and don't catch will now see the exception. It is documented in doc/Learn/UpdatingExtensions.md and was accepted in review.

Other information

Not run locally: the Android, iOS, WebAssembly and WinAppSDK lanes (CI covers them). Windows Skia Desktop (http.sys HttpListener) is not exercised by CI or by the local runs, which were on macOS. The provider is compiled out on WinAppSDK (#if !WINDOWS), where WinUIEx handles the activation.

🤖 Generated with Claude Code

https://claude.ai/code/session_015tKeWCuqJ7QVyKcChvivDX


This is an automatic backport of pull request #3261 done by [Mergify](https://mergify.com).

kazo0 and others added 8 commits October 27, 2026 13:25
…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
(cherry picked from commit cd2135d)

# Conflicts:
#	Uno.Extensions.sln
#	doc/Learn/UpdatingExtensions.md
…Ms so its platform gate applies

The suite is compiled out with `#if !__ANDROID__ && !__IOS__ && !__WASM__`,
which only works when the project has those TFM flavours. With the library
TFM list it was a single net10.0 build that every head loaded, so the
loopback-listener tests ran inside the WebAssembly and mobile runtime-test
hosts. Imports tfms-ui-winui-apps.props like the MSAL test project does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
(cherry picked from commit d3e1b11)
- specs/018: add "bindables" and "INDEI" to build/ci/cspell.json
- specs/019 progress and specs/lessons.md: drop the trailing blank line (MD012)
- Both fail the Docs Validations stage for every PR built against main

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EouKGNoa82gPgVtVHaSAre
(cherry picked from commit fd9e9e6)

# Conflicts:
#	specs/019-mvux-selection-refresh/progress.md
#	specs/lessons.md
…ticationBroker

- TryRegister checks the registry first, returns true only when this broker is the registered provider, logs when another provider won, and runs after the hostBuilder null guard in AddWeb/AddWeb<T>/AddOidc
- OidcAuthenticationProvider re-reads the broker callback before every login/logout with AutoRedirectUri, so a port the broker had to forget is not kept from the Build() snapshot
- WebAuthenticatorBrowser maps the broker's status and TimeoutErrorDetail to BrowserResultType (Timeout, UserCancel, HttpError) instead of dropping them
- Broker: dual-family default-port probe, non-loopback requests rejected at the socket, per-flow Debug logs and a named launcher on Win32Exception, browser launch off the caller's thread, pooled form-post buffer, Cache-Control: no-store, protected ILogger constructor; file moved to match its namespace
- Tests: the static WebAuthenticationBroker driven end to end through a shared registered double (callback, success, timeout detail, second-flow rejection, cancellation, first-wins), a token-leak guard over every response and error path, the OIDC redirect red/green case and the browser-result mapping; [DoNotParallelize]
- Docs: no {State} reference, the Web provider's missing request binding stated, #if !WINDOWS and enableUnoLogging notes, the "registered after" case in UpdatingExtensions
- specs/020 progress with every finding and its status; two lessons on Uno's static-ctor provider snapshot and the cached per-type logger

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EouKGNoa82gPgVtVHaSAre
(cherry picked from commit 635ae43)

# Conflicts:
#	specs/lessons.md
…esktop sign-out returns

- OidcAuthenticationProvider.LogoutAsync passed no id_token_hint, so the identity provider would not redirect to PostLogoutRedirectUri and the desktop loopback broker waited out its five-minute timeout
- Pass the cached id_token as LogoutRequest.IdTokenHint and the caller's CancellationToken to LogoutAsync
- Red/green: Given_OidcAuthenticationProvider.When_Logout_Then_CachedIdTokenSentAsHint
- Verified live against the Uno.Samples OIDC demo on macOS desktop with packages packed from this branch
- Document the hint in HowTo-OidcAuthentication and the spec 020 progress note

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EouKGNoa82gPgVtVHaSAre
(cherry picked from commit 92c8c2d)
…bAuthenticationBroker

- Broker: a failed browser launch no longer logs or rethrows the launcher's exception, whose message on Windows is the request URL (login_hint, and id_token_hint on sign-out); the log carries the launcher name and native error code, the caller gets a Win32Exception with a fixed message and no inner exception
- WebAuthenticatorBrowser: the caller's cancellation propagates as OperationCanceledException so a cancelled sign-out takes the token-clearing exception path; the OIDC client's own BrowserOptions.Timeout maps to Timeout; NotImplementedException from Uno's stub broker names TryRegister/AddOidc; both CTSs disposed; ILogger injected; XML docs
- Registration: the outcome of TryRegister is logged through the host's ILogger once built (IServiceInitialize) instead of at builder time, where no logger exists; the registration itself stays at builder time, ahead of any static-broker touch
- Pooled form-post buffer cleared on return and sized to stay off the LOH; one protected constructor; dead negative platform list removed; TryRegister's returns states the early-touch limit
- Tests (red/green): launch-failure token guard, OIDC-timeout-first, caller cancel, not-implemented mapping, registration outcome reaching a built host's logger once; guards for the no-id_token hint and logout-cancel propagation; EnsureRegistered proves the static broker bound to the double
- Docs: the NotImplementedException symptom and the logging categories in both HowTo pages; the cross-platform OIDC behaviour changes in UpdatingExtensions
- specs/020 second-round table; lesson on Process.Start exception messages

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EouKGNoa82gPgVtVHaSAre
(cherry picked from commit 51fc86f)

# Conflicts:
#	specs/lessons.md
…ts registration

- Rebuild the result from the callback's OriginalString, so the Web provider's StartsWith match survives a mixed-case host or an explicit default port
- Resolve the registry after Register to confirm the loopback broker won, instead of assuming it
- Move the default-port reset into a static helper
- Docs: the registration line needs the Uno host and CoreLogLevel Information; a cancelled login now throws and keeps the stored tokens

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015tKeWCuqJ7QVyKcChvivDX
(cherry picked from commit 7e79bf1)
- 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
(cherry picked from commit 57a33be)
@mergify mergify Bot added the conflicts label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown
Author

Cherry-pick of cd2135d has failed:

On branch mergify/bp/servicing/7.4/pr-3261
Your branch is up to date with 'origin/servicing/7.4'.

You are currently cherry-picking commit cd2135d.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   build/ci/.azure-pipelines.yml
	modified:   doc/Learn/Authentication/HowTo-OidcAuthentication.md
	modified:   doc/Learn/Authentication/HowTo-WebAuthentication.md
	modified:   src/Uno.Extensions.Authentication.Oidc/HostBuilderExtensions.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/Given_DesktopWebAuthenticationBroker.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/Uno.Extensions.Authentication.WinUI.Tests.csproj
	modified:   src/Uno.Extensions.Authentication.UI/HostBuilderExtensions.cs
	new file:   src/Uno.Extensions.Authentication.UI/Web/DesktopWebAuthenticationBrokerProvider.cs
	modified:   src/Uno.Extensions.RuntimeTests/Uno.Extensions.RuntimeTests/Uno.Extensions.RuntimeTests.csproj

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   Uno.Extensions.sln
	both modified:   doc/Learn/UpdatingExtensions.md

Cherry-pick of fd9e9e6 has failed:

On branch mergify/bp/servicing/7.4/pr-3261
Your branch is ahead of 'origin/servicing/7.4' by 2 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit fd9e9e6.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   build/ci/cspell.json
	renamed:    src/Uno.Extensions.Authentication.UI/Web/DesktopWebAuthenticationBrokerProvider.cs -> src/Uno.Extensions.Authentication.UI/DesktopWebAuthenticationBrokerProvider.cs

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   specs/019-mvux-selection-refresh/progress.md
	both modified:   specs/lessons.md

Cherry-pick of 635ae43 has failed:

On branch mergify/bp/servicing/7.4/pr-3261
Your branch is ahead of 'origin/servicing/7.4' by 3 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 635ae43.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   doc/Learn/Authentication/HowTo-OidcAuthentication.md
	modified:   doc/Learn/Authentication/HowTo-WebAuthentication.md
	modified:   doc/Learn/UpdatingExtensions.md
	new file:   specs/020-desktop-web-auth-broker/progress.md
	modified:   src/Uno.Extensions.Authentication.Oidc/HostBuilderExtensions.cs
	modified:   src/Uno.Extensions.Authentication.Oidc/OidcAuthenticationProvider.cs
	modified:   src/Uno.Extensions.Authentication.Oidc/Uno.Extensions.Authentication.Oidc.WinUI.csproj
	modified:   src/Uno.Extensions.Authentication.Oidc/WebAuthenticatorBrowser.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/CapturingLogger.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/Given_DesktopWebAuthenticationBroker.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/Given_OidcAuthenticationProvider.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/Given_WebAuthenticatorBrowser.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/TestBroker.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/Uno.Extensions.Authentication.WinUI.Tests.csproj
	modified:   src/Uno.Extensions.Authentication.UI/DesktopWebAuthenticationBrokerProvider.cs
	modified:   src/Uno.Extensions.Authentication.UI/HostBuilderExtensions.cs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   specs/lessons.md

Cherry-pick of 51fc86f has failed:

On branch mergify/bp/servicing/7.4/pr-3261
Your branch is ahead of 'origin/servicing/7.4' by 5 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 51fc86f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   doc/Learn/Authentication/HowTo-OidcAuthentication.md
	modified:   doc/Learn/Authentication/HowTo-WebAuthentication.md
	modified:   doc/Learn/UpdatingExtensions.md
	modified:   specs/020-desktop-web-auth-broker/progress.md
	modified:   src/Uno.Extensions.Authentication.Oidc/HostBuilderExtensions.cs
	modified:   src/Uno.Extensions.Authentication.Oidc/WebAuthenticatorBrowser.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/CapturingLogger.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/Given_DesktopWebAuthenticationBroker.cs
	new file:   src/Uno.Extensions.Authentication.UI.Tests/Given_DesktopWebAuthenticationBrokerRegistration.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/Given_OidcAuthenticationProvider.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/Given_WebAuthenticatorBrowser.cs
	modified:   src/Uno.Extensions.Authentication.UI.Tests/TestBroker.cs
	new file:   src/Uno.Extensions.Authentication.UI/DesktopWebAuthenticationBrokerHostBuilderExtensions.cs
	modified:   src/Uno.Extensions.Authentication.UI/DesktopWebAuthenticationBrokerProvider.cs
	modified:   src/Uno.Extensions.Authentication.UI/HostBuilderExtensions.cs
	modified:   src/Uno.Extensions.Authentication.UI/Uno.Extensions.Authentication.WinUI.csproj

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   specs/lessons.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

- Uno.Extensions.sln: keep only the auth test project and its folder (drop main's Navigation.Tests context)
- UpdatingExtensions.md: move the Web/OIDC note into the 7.4 section; 7.4 has no 8.0 section
- Test project: import tfms-ui-winui.props, since tfms-ui-winui-apps.props is 8.0-only
- Drop the MVUX selection spec and lesson pulled in by the conflict resolution; that fix is not on 7.4

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015tKeWCuqJ7QVyKcChvivDX
@kazo0 kazo0 removed the conflicts label Oct 27, 2026
@kazo0

kazo0 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Fixed the conflicts in 482e298:

  • Uno.Extensions.sln: kept only the Uno.Extensions.Authentication.WinUI.Tests entries. The conflict context from main also contained Uno.Extensions.Navigation.Tests, which isn't in the 7.4 solution, so I left it out.
  • UpdatingExtensions.md: 7.4 has no 8.0 section, so the Web/OIDC note now sits under "Upgrading to Extensions 7.4", together with the cancellation behavior change.
  • Test project: it imports tfms-ui-winui.props now, because tfms-ui-winui-apps.props only exists on 8.0.
  • I removed specs/019-mvux-selection-refresh/progress.md and the MVUX Selection lesson. They came in through the conflict resolution of the lint-fix commit, and that MVUX fix isn't on 7.4.

Verified on macOS: the auth libraries and the test project build in Release (net9.0, net9.0-desktop, net9.0-browserwasm). The auth runtime suite passes 34/34 on the net9.0-desktop runtime-tests head. Markdownlint and cspell are clean. Android, iOS, Mac Catalyst and Windows weren't built locally because the net9 workloads aren't installed here, so CI covers those.

@kazo0
kazo0 merged commit ad9e607 into servicing/7.4 Oct 27, 2026
24 checks passed
@kazo0
kazo0 deleted the mergify/bp/servicing/7.4/pr-3261 branch October 27, 2026 14:19
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.

1 participant