[CmdPal] Host-side OAuth redirect broker (Phase 2) - #49441
Draft
michaeljolley wants to merge 1 commit into
Draft
Conversation
Add the Command Palette host broker that backs the built-in authorization flow defined by the Phase 1 SDK contract. Command Palette acts as a thin, hardened redirect broker: it allocates the redirect target, injects a cryptographically random state, opens the browser, captures the single redirect, validates state, and returns the raw response parameters to the extension. It never sees the PKCE verifier and never stores third-party tokens. Details: - AuthBrokerService: state generation and single-use validation, parameter composition, loopback and custom-scheme flows, timeout/cancel/concurrency handling, and non-blocking status via the host. - Loopback listener bound to 127.0.0.1 only (no HTTP.SYS ACL, no elevation). - Custom scheme x-cmdpal://auth/callback routed by state from MainWindow.HandleLaunchNonUI. - AppExtensionHost implements IExtensionHost2.RequestAuthorizationAsync. - Testability seams (platform, listener factory) with fakes; 14 Auth unit tests plus a real loopback TCP integration test. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2ee31cb3-848f-43ba-ac48-f4e4485baa33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the Command Palette built-in OAuth authorization flow: the host-side redirect broker. This is the second of a stack of 4 draft PRs and targets the Phase 1 branch (
dev/mjolley/cmdpal-auth-flow, #49440).Command Palette acts as a thin, hardened redirect broker. It allocates the redirect target, injects a cryptographically random
state, opens the browser, captures the single redirect, validatesstate, and hands the raw response parameters back to the extension. Command Palette never sees the PKCE verifier and never stores third-party tokens; the Toolkit'sOAuthClientperforms the code exchange inside the extension's process.What this adds
AuthBrokerService(Microsoft.CmdPal.UI.ViewModels/Auth): 256-bitstategeneration with single-use, fixed-time validation; parameter composition (appendsredirect_uriandstate); loopback and custom-scheme flows; timeout (default 60s, cap 300s), cancellation, concurrency, and teardown handling; non-blocking status via the host. Auth codes and tokens are never logged.127.0.0.1only via a rawTcpListener, so no HTTP.SYS URL ACL and no elevation are required inside the packaged process.x-cmdpal://auth/callbackrouted bystatefromMainWindow.HandleLaunchNonUI, reusing the existing single-instance protocol activation wiring.AppExtensionHostimplementsIExtensionHost2.RequestAuthorizationAsync, delegating to the broker.IAuthBrokerPlatform,ILoopbackRedirectListenerFactory) with a default platform and a UI platform that re-foregrounds the window on capture.Testing
build.ps1 -Path src\modules\cmdpal -Platform x64 -Configuration Debug, exit code 0.*.UnitTestsprojects pass with zero failures.Scope
Changes are limited to
src/modules/cmdpal(CommandPalette.slnf). No XAML changed. Draft while the rest of the stack lands.