Skip to content

[CmdPal] Add OAuth sign-in sample and authentication spec (Phase 4) - #49443

Draft
Michael Jolley (michaeljolley) wants to merge 1 commit into
dev/mjolley/dev-mjolley-cmdpal-auth-navfrom
dev/mjolley/cmdpal-auth-sample
Draft

[CmdPal] Add OAuth sign-in sample and authentication spec (Phase 4)#49443
Michael Jolley (michaeljolley) wants to merge 1 commit into
dev/mjolley/dev-mjolley-cmdpal-auth-navfrom
dev/mjolley/cmdpal-auth-sample

Conversation

@michaeljolley

Copy link
Copy Markdown
Contributor

Summary

Phase 4 (final phase) of the built-in Command Palette authentication feature. This is a stacked draft PR on top of Phase 3 (dev/mjolley/dev-mjolley-cmdpal-auth-nav).

It adds a demonstration OAuth sign-in sample to SamplePagesExtension and the feature spec doc.

Sample (src/modules/cmdpal/ext/SamplePagesExtension)

  • SampleOAuthPage (entry page): offers a demo sign-in, and shows a graceful "not available" message when ExtensionHost.SupportsAuthorization is false.
  • OAuthSignInCommand: runs Authorization Code + PKCE via the Phase 1 Toolkit OAuthClient (secretless public client, loopback redirect). Defaults target the Duende IdentityServer public demo (demo.duendesoftware.com, interactive.public, scope openid profile); the constants are labeled as demo values and can be swapped for a developer's own registered client. On success it optionally persists via CredentialManagerTokenStore (guarded), then calls the Phase 3 ExtensionHost.GoToPageAsync(new SampleSignedInPage(token), NavigationMode.Push).
  • SampleSignedInPage: a ContentPage + MarkdownContent landing page that renders non-sensitive session facts only (token type, scope, expiry, whether a refresh/id token was received). It never renders the raw token.
  • Registered the entry page in SamplesListPage.cs.

Docs

  • src/modules/cmdpal/doc/authentication.md: feature spec covering the host-broker vs Toolkit split, a mermaid sequence diagram of the full flow, the SDK contract (IExtensionHost2, IAuthorizationRequest/IAuthorizationResult, AuthorizationRedirectKind, NavigationMode), capability detection and NotSupportedException behavior, the security model (PKCE, single-use host-owned state, redirect_uri binding, 127.0.0.1-only loopback, no host token storage, timeout caps), token-storage guidance (ITokenStore / CredentialManagerTokenStore + PasswordVault size caveat), and a bring-your-own-provider GitHub example.

No secrets are committed (PKCE public client only). No emdashes.

Verification

  • Build: tools\build\build.ps1 -Path src\modules\cmdpal -Platform x64 -Configuration Debug -> exit code 0.
  • All CmdPal *.UnitTests run with --no-build (built MTP DLLs via the x64 dotnet host): 2483 total, 0 failed, 2481 passed, 2 skipped (pre-existing skips in Shell and Toolkit). Ext.WindowWalker reports 0 tests (no test methods), as expected.

Honest caveat

An interactive OAuth flow cannot be verified end to end in an unattended session (it requires a human to sign in via a browser against a real IdP). The live sign-in was NOT runtime verified. The verification bar met here is build exit 0 plus green unit tests. The sample and its comments describe it as illustrative.

@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jul 21, 2026
Phase 4 of the built-in Command Palette authentication feature.

Sample (SamplePagesExtension):
- SampleOAuthPage: entry page that offers a demo sign-in and shows a
  graceful message when the host does not support authorization.
- OAuthSignInCommand: runs Authorization Code + PKCE via the Toolkit
  OAuthClient (secretless public client, loopback redirect, Duende public
  demo defaults), optionally persists with CredentialManagerTokenStore,
  then calls ExtensionHost.GoToPageAsync to navigate to the signed-in page.
- SampleSignedInPage: landing page rendering non-sensitive session facts
  only (never the raw token).
- Registered the entry page in SamplesListPage.

Docs:
- src/modules/cmdpal/doc/authentication.md: feature spec covering the
  host-broker vs Toolkit split, a mermaid sequence diagram, the SDK
  contract, capability detection, the security model, token-storage
  guidance, and a bring-your-own-provider GitHub example.

The sample is illustrative. Running it needs a real identity provider and
an interactive browser sign-in, so the live flow was not runtime verified.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 2ee31cb3-848f-43ba-ac48-f4e4485baa33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.102 Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants