Skip to content

feat(samples): add the OIDC authentication extensions demo - #969

Merged
kazo0 merged 8 commits into
masterfrom
dev/sb/oidc-extensions-demo
Oct 30, 2026
Merged

kazo0 merged 8 commits into
masterfrom
dev/sb/oidc-extensions-demo

Conversation

@kazo0

@kazo0 kazo0 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds UI/Authentication.OidcExtensionsDemo, a single-project Uno app demonstrating Uno.Extensions OpenID Connect authentication (AddOidc) across Desktop (Skia), WebAssembly, Android and iOS. It is the OIDC counterpart of UI/Authentication.MsalExtensionsDemo (#948): same three pages, same flow log, so the two providers can be compared side by side.

What it demonstrates

  • Flow log — narrates every IAuthenticationService call: the silent startup refresh, interactive sign-in with the redirect URI in use, the stored tokens with the ID token's claims decoded, sign-out, and every LoggedOut event.
  • Call the API — GET /api/test on the Duende demo server through a Refit client registered inside UseHttp, so the handler Uno.Extensions chains in adds the bearer token and refreshes on 401. Signed out, the same call answers 401.
  • Platform setup page — what each head needs and why, with the running head marked: the loopback redirect URI on desktop, the broker's {origin}/authentication-callback on WebAssembly, the intent-filter scheme on Android, the CFBundleURLTypes entry and keychain entitlement on iOS.
  • Redact switch — hides the client ID, the account and anything token-shaped, so the app can be recorded.

Configuration

It runs as is: appsettings.development.json points at the Duende demo server's interactive.public client (code flow with PKCE, no secret, any redirect URI accepted), sign in as alice / alice. The README covers pointing it at another identity provider, and the redirect scheme oidcdemo is the one value that has to change in four places (appsettings, the Android activity, Info.plist, Package.appxmanifest).

Two things the sample does that a template app does not, both explained in the README's Versions section:

  • The desktop head overrides RedirectUri and PostLogoutRedirectUri through configuration (an in-memory source over appsettings) with http://localhost:52001/authentication-callback, because OIDC code options replace the whole section rather than merging with it.
  • App.xaml.cs adds a log filter at Information for Uno.Extensions.Authentication, so the console says which WebAuthenticationBroker is handling the flow.

Packages

Uno.Sdk 7.0.0-dev.115
Uno.Extensions (pinned by the Sdk) 8.0.0-dev.150

Desktop sign-in needs Uno.Extensions 8.0.0-dev.135 or later: the first version whose AddOidc registers a loopback WebAuthenticationBroker on Windows, macOS and Linux (unoplatform/uno.extensions#3261) and sends the cached ID token as id_token_hint on sign-out. Uno.Sdk 7.0.0-dev.95 and later pin it (dev.95 pins Uno.Extensions 8.0.0-dev.147), so the sample no longer overrides UnoExtensionsVersion.

Temporary: the csproj references Uno.WinUI.Lottie in Debug builds only. Even on Uno.Sdk 7.0.0-dev.115, the App MCP client that Debug builds carry (Uno.UI.App.Mcp.Client 2.0.0-dev.18) references Uno.UI.Lottie, which Uno.WinUI no longer ships, and a Debug build dies at startup without it (unoplatform/uno.extensions#3262). Release builds start without it. The reference can go once the tooling packages are rebuilt.

Verification

All against the Duende demo server:

  • Desktop (Skia), macOS — Uno.Sdk 7.0.0-dev.115 / Uno.Extensions 8.0.0-dev.150: sign-in through the provider's loopback broker, GET /api/test 200, silent sign-in after a restart. Sign-out (returning through the identity provider's link and raising LoggedOut) and the 20-claim check were last run on Uno.Sdk 7.0.0-dev.89 / Uno.Extensions 8.0.0-dev.135.
  • WebAssembly, Chrome — Uno.Sdk 7.0.0-dev.89 / Uno.Extensions 8.0.0-dev.135: sign-in popup lands on /authentication-callback and closes; sign-out popup offers the link back and the broker closes it.
  • Android, API 36 emulator — last run on Uno.Sdk 7.0.0-dev.77 / Uno.Extensions 8.0.0-dev.85: Chrome custom tab, oidcdemo://callback intent back to the app, API 200, sign-out.
  • iOS, iPhone 16 simulator (iOS 18.5) — Uno.Sdk 7.0.0-dev.89 / Uno.Extensions 8.0.0-dev.135: sign-in through ASWebAuthenticationSession with the oidcdemo scheme, silent refresh after a restart (refresh token from the keychain), GET /api/test 200, sign-out returning through the identity provider's link and raising LoggedOut.

Known issue found while testing iOS (not in this PR)

A trimmed iOS build breaks the API client. With TrimMode=partial, which iOS Release builds use by default, the trimmer removes EndpointOptions.Url's setter from Uno.Extensions.Http, because only ConfigurationBinder reaches it by reflection. The DemoApi section then binds to an object with a null Url, and the Refit call fails with "BaseAddress must be set on the HttpClient instance". Seen on the simulator built with MtouchLink=SdkOnly; the bundled Uno.Extensions.Http.dll had no set_Url, and adding <TrimmerRootAssembly Include="Uno.Extensions.Http" /> fixed it. A Release device build was not tried. It affects Kiota clients too and any trimmed Release build (iOS, Android, WebAssembly): filed as unoplatform/uno.extensions#3266, fixed with a CI regression test in unoplatform/uno.extensions#3267. The sample's default Debug simulator build does not trim, so it is unaffected.

Notes for reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV

kazo0 and others added 6 commits October 23, 2026 14:26
…e and keychain entitlement

Verified on Android (API 36 emulator): sign-in through Chrome and the
oidcdemo:// intent, the authenticated API call, and sign-out.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
…torage, adds the id_token_hint on any end-session URL, registers the API serializer context

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
…tensions 8.0.0-dev.135 loopback broker

Uno.Extensions 8.0.0-dev.135 (uno.extensions#3261) makes AddOidc register a loopback
WebAuthenticationBroker on Windows, macOS and Linux and sends id_token_hint on sign-out,
so the sample's own SystemBrowser IBrowser goes away. The desktop head now only overrides
the redirect URIs through configuration with http://localhost:52001/authentication-callback.
No Uno.Sdk pins dev.135 yet: Directory.Build.props raises UnoExtensionsVersion, global.json
moves to Uno.Sdk 7.0.0-dev.89 (dev.135 is built against its Uno.WinUI and Toolkit pins), and
a Debug-only Uno.WinUI.Lottie reference keeps the Hot Design / App MCP tooling from failing
at startup (uno.extensions#3262). A log filter at Information for Uno.Extensions.Authentication
shows which broker handles the flow. README, in-app platform guide and troubleshooting
describe the new behaviour; verified end to end on desktop (sign-in, API call, sign-out
returning through the identity provider's link) and on WebAssembly (sign-out popup now
offers the link back and the broker closes it).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
Sign-in through ASWebAuthenticationSession, silent refresh after a restart, the API call
and sign-out through the identity provider's link, on an iOS 18.5 simulator with
Uno.Sdk 7.0.0-dev.89 and Uno.Extensions 8.0.0-dev.135.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Sn8GmJ41W3eBgT7866J3jV
… drops the Uno.Extensions override

Uno.Sdk 7.0.0-dev.95 and later pin Uno.Extensions 8.0.0-dev.147+, which has the desktop
loopback WebAuthenticationBroker (unoplatform/uno.extensions#3261), so Directory.Build.props
no longer raises UnoExtensionsVersion. The Debug-only Uno.WinUI.Lottie reference stays:
Uno.UI.App.Mcp.Client 2.0.0-dev.18 still references Uno.UI.Lottie and a Debug build without
it fails at startup (unoplatform/uno.extensions#3262). Desktop sign-in, the API call and the
silent sign-in after a restart were checked on macOS with the new versions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75jaJiiGCSEDPc39foS
@kazo0
kazo0 marked this pull request as ready for review October 30, 2026 19:59
@kazo0
kazo0 merged commit 1ed7bac into master Oct 30, 2026
10 checks passed
@kazo0
kazo0 deleted the dev/sb/oidc-extensions-demo branch October 30, 2026 21:28
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