Repository navigation
Authenticate GitHub marketplace API requests via RFC 8693 token exchange - #325815
Michael Cummings (MSFT) (mcumming) wants to merge 20 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds RFC 8693 GitHub token exchange for authenticated Private Marketplace deployments, alongside stacked Entra authentication groundwork.
Changes:
- Negotiates and distributes resource-scoped marketplace tokens.
- Attaches tokens to protected gallery and resource requests.
- Adds provider-aware UI, policy configuration, caching, and tests.
Show a summary per file
| File | Description |
|---|---|
build/lib/policies/policyData.jsonc |
Exports the auth-provider policy. |
product.json |
Registers Microsoft trusted auth access. |
src/vs/base/common/product.ts |
Adds the Entra product gate. |
src/vs/platform/extensionManagement/common/extensionGalleryManifest.ts |
Defines auth metadata, token exchange, states, and APIs. |
src/vs/platform/extensionManagement/common/extensionGalleryManifestService.ts |
Provides the default token implementation. |
src/vs/platform/extensionManagement/common/extensionGalleryManifestServiceIpc.ts |
Transfers negotiated tokens over IPC. |
src/vs/platform/extensionManagement/common/extensionGalleryService.ts |
Authenticates gallery API and asset requests. |
src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts |
Adds guarded resource authorization headers. |
src/vs/platform/extensionResourceLoader/common/extensionResourceLoaderService.ts |
Authenticates native resource requests. |
src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.ts |
Authenticates browser resource requests. |
src/vs/workbench/contrib/extensions/common/extensions.ts |
Re-exports the provider context key. |
src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts |
Adds provider-aware marketplace status UI. |
src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts |
Registers policy and provider-routed sign-in. |
src/vs/workbench/services/extensionManagement/electron-browser/extensionGalleryManifestService.ts |
Implements negotiation, eligibility, caching, and invalidation. |
src/vs/workbench/services/extensionManagement/test/electron-browser/extensionGalleryManifestService.test.ts |
Tests provider and negotiation scenarios. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 5
- Review effort level: Medium
|
TylerLeonhardt some oauth changes here, if interested in reviewing. |
0e72de5 to
a2f5f81
Compare
|
Thanks for the PR - LGTM |
|
Michael Cummings (MSFT) (@mcumming) Can you please update the PR by merging the main and resolving the conflicts? |
0938b44 to
524003e
Compare
Compatibility with the focused post-merge fixesVerified the unchanged GitHub feature head Tested revisions: #343690 through Result: 300 selected tests passed, 0 failed. Native client compilation, changed-file hygiene, module/type layer checks, and aggregate whitespace checks also passed. The actual cache PR's corrected test file exactly matches the validated integration file, and all four final request transport/test/harness files match the redirect PR. The existing Kerberos lookup case remains excluded because its native/module dependency is unavailable; the same unrelated failure was reproduced on unmodified upstream code. This is compatibility evidence, not live deployment validation or security approval. Exact final combined test command, from the isolated integration workspace: $env:VSCODE_SKIP_PRELAUNCH = '1'
.\scripts\test.bat --reporter dot --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryAccountService.test.ts --run src\vs\platform\request\test\node\requestService.test.ts --run src\vs\platform\request\test\electron-main\requestService.test.ts --run src\vs\base\test\common\oauth.test.ts --grep 'WorkbenchExtensionGalleryManifestService|MicrosoftGalleryAccountProvider|OAuth|Request Service(?! Kerberos lookup)'
Rebase notes for keeping reviews separate:
All four outstanding AI review threads across the focused PRs have been replied to and resolved. Human approval of OAuth/renewal and Node/Electron redirects is still required, including the explicit remote credential-delegation review at #343689 (comment). Drafted with GitHub Copilot. |
|
Thanks for updating the PR. The marketplace integration looks consistent with the previous review—the existing TylerLeonhardt could you review the GitHub token exchange and renewal lifecycle, particularly expiry scheduling and recovery from transient failures? A temporary renewal failure should not immediately turn an available marketplace into “Requires sign-in.” Christof Marti (@chrmarti) could you review the request-service redirect changes, including Electron behavior? Since these affect all request-service consumers, I’d prefer landing them separately via #343690 and rebasing this PR on that fix. |
Sandeep Somavarapu (sandy081)
left a comment
There was a problem hiding this comment.
Approving the marketplace integration and service structure from my side. This approval does not cover the OAuth token exchange/renewal or request-service redirect behavior.
TylerLeonhardt please review the OAuth token exchange and renewal lifecycle. Christof Marti (@chrmarti) please review the Node/Electron request-service redirect changes.
I’m moving this PR to draft pending those reviews. Please mark it ready and merge only after all three of us (Sandeep Somavarapu (@sandy081), TylerLeonhardt, and Christof Marti (@chrmarti)) have approved and the outstanding concerns have been resolved.
524003e to
49fe2a3
Compare
e0fed27 to
588529d
Compare
Karthik Nadig (karthiknadig)
left a comment
There was a problem hiding this comment.
I looked at the two new commits responding to Tyler. Moving Connor's Entra-aware comparison into the shared helper makes sense, but removing the opt-in means issuer validation now applies to every caller of fetchAuthorizationServerMetadata, not just the marketplace and Agent Host. That includes third-party MCP OAuth in extHostMcp, dynamic auth providers and XAA in mainThreadAuthentication, and extHostXaaAuthProvider.
That is a user-visible change, for MCP in particular (inline). The PR description doesn't mention it, and no test covers the affected path. Could you confirm with Tyler and Connor that enabling it for all callers is intended? If it is, I'd split it into its own PR so the MCP owners can review it and it can be reverted independently. If not, keep it opt-in for the marketplace and Agent Host.
Review assisted by Copilot.
When a GitHub-provider marketplace is gated, discover its protected resource (RFC 9728) and exchange the default account's GitHub session token at the marketplace's authorization server (RFC 8693). The subject token is only sent to a same-origin HTTPS token endpoint, with redirects disabled, and the RFC 8414 issuer is validated. Re-validate on GitHub session changes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
…e exchanged GitHub token The node request service now strips Authorization and Cookie when a redirect leaves the origin, so every token-bearing marketplace request is protected. The GitHub provider re-resolves the account before the exchanged token expires so protected requests do not start failing. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
4716df8 to
131f837
Compare
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
|
TylerLeonhardt Christof Marti (@chrmarti) this is ready for your re-review 🙏 |
Use the authentication provider's remaining lifetime to schedule silent resource-token renewal. Coalesce account resolutions, cancel stale generations, retain available manifests during transient failures, and publish rotated process snapshots. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 859d436-9028-4925-a02c-73264226d5f8
…lures Distinguish failed renewal of the same account and gallery from initial consent and account switches. Exercise a resource-session failure rather than an identity-session proxy, and ensure a different account cannot keep the previous bearer. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 859d436-9028-4925-a02c-73264226d5f8
Avoid introducing polling or a second renewal cadence for GitHub and other account providers. Clear retry ownership when the provider or marketplace changes, and exercise both initial failures and provider replacement. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 859d436-9028-4925-a02c-73264226d5f8
Separate marketplace credential projection from catalog notifications and recover current-bearer failures through one coalesced silent renewal path. Preserve account/cancellation guards and safe request replay. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 859d436-9028-4925-a02c-73264226d5f8
Share a one-minute completion cooldown across rejection reporters and rotating bearers. Avoid forcing the same rejected current credential twice, retain a server-accepted catalog when renewal returns an unchanged bearer, and preserve genuine authentication failure handling. Cover remote/shared rejection loops, exact cooldown boundaries, slow and failed refreshes, normal expiry renewal, and account/session-change races. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 859d436-9028-4925-a02c-73264226d5f8
Retain the merge-only regression coverage from df60f49 in the rebased history: same-origin, cross-origin and out-and-back authorization proof, renewable-account 403 handling without forced renewal, and metadata-cache reuse during expiry renewal. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b972512b-5cf0-4fb8-88b3-ef6b24a19441
| * `chatSetupMicrosoftProbe.ts`. | ||
| */ | ||
| const WORKBENCH_INCLUDE_UNAPPROVED_ACCOUNTS = '_workbenchIncludeUnapprovedAccounts'; | ||
| const WORKBENCH_FORCE_REFRESH = '_workbenchForceRefresh'; |
There was a problem hiding this comment.
Nope, do not do this. This is a hack. WORKBENCH_INCLUDE_UNAPPROVED_ACCOUNTS was only for a specific scenario and temporary. We do not wanna depend on private contracts between Core and the Extension.
There was a problem hiding this comment.
Thanks, agreed. The private refresh contract is now removed from both branches. Token renewal is handled inside the auth extension.
Changes
-
Renew marketplace resource tokens before expiry #343688 (
dev/mcumming/marketplace-auth-follow-ups): 0699fc5 -
This PR (
github-marketplace-api-auth): 9900923 (same change, synced) -
Removed
_workbenchForceRefresh/WORKBENCH_FORCE_REFRESHfromauthProvider.ts,authentication.ts, and the gallery account service and provider.authProvider.tsnow matchesmain. -
CachedPublicClientApplicationnow refreshes on its own. If MSAL returns a cached access token that expires within 5 minutes (newisAccessTokenNearExpiryhelper insrc/common/tokenExpiry.ts), it forces a silent refresh through the existing sequencer. With the broker this uses the claims request; otherwise it usesforceRefresh: true. If that refresh fails, it keeps the cached token while it is still unexpired and rethrows once it has expired. The workbench now gets fresh tokens through the publicgetSessionpath with no special options.
WORKBENCH_INCLUDE_UNAPPROVED_ACCOUNTS
I left it alone. It is not part of this PR: it is already on main from #338823 and used by the chat-setup Microsoft probe (chatSetupMicrosoftProbe.ts). Removing it would break that feature, so it should be handled separately with the chat-setup owners.
Tradeoff
Without a forced-refresh option, a 401 on a token that was revoked but hasn't expired can no longer force a silent refresh. The 401 retry still asks again, but it may get the same cached token, and then the existing cooldown applies. It recovers once the token is near expiry, or after the user signs out and back in. If faster 401 recovery is needed, I think a public challenge-based API is the right route, not another sentinel.
Validation (run locally on 9900923)
build-fast --client-onlypassed.extensionGalleryManifestService.test.ts+extensionGalleryAccountService.test.ts: 278 passing.typecheck-clientand the extensiontsc --noEmitboth exited 0.- eslint on the changed files exited 0.
compile-extension:microsoft-authenticationfinished with 0 errors.- The
tokenExpirymocha test passed (1 test). - I did not exercise live sign-in or the broker flow.
This reply was drafted by an AI agent (GitHub Copilot) on behalf of Michael Cummings (MSFT) (@mcumming).
There was a problem hiding this comment.
VSPM has decided CAE and claims challenges are non-goals. Revoked-token recovery relies on the server's planned invalid_token response and near-expiry renewal of short-lived non-CAE tokens. In #343688, if silent resolution returns the rejected token, sign-in is required; insufficient_claims is only a defensive sign-in fallback. Neither a cache bypass nor a public forceRefresh API is planned.
This reply was drafted by an AI agent (GitHub Copilot) on behalf of Michael Cummings (MSFT) (@mcumming).
…orkbench sentinel Remove the private _workbenchForceRefresh / WORKBENCH_FORCE_REFRESH contract between the workbench and the microsoft-authentication extension. The extension now forces a silent refresh itself when a cached access token is within five minutes of expiry, falling back to the cached token if the refresh fails before expiry. Mirrors the change on dev/mcumming/marketplace-auth-follow-ups. Co-authored-by: Copilot App <[email protected]>
Part of #325412. This PR adds GitHub authentication for a private extension marketplace. It currently includes the shared marketplace renewal work from #343688, which remains a separate prerequisite PR; the combined diff is temporary.
Changes
Validation
Passed: 381 tests, using incrementally transpiled client output and the Node unit harness:
Passed:
node .\node_modules\eslint\bin\eslint.js src\vs\workbench\services\extensionManagement\common\extensionGalleryAccount.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryAccountService.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryManifestService.ts src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts.Passed:
node build\lib\formatter.ts --verify src\vs\workbench\services\extensionManagement\common\extensionGalleryAccount.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryAccountService.ts src\vs\workbench\services\extensionManagement\electron-browser\extensionGalleryManifestService.ts src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts.Blocked:
node .\node_modules\@typescript\native\bin\tsc --project .\src\tsconfig.json --noEmit --skipLibCheckreports errors in unrelated code against stale installed dependencies, including the Copilot SDK; no marketplace-file diagnostics were reported. The Node tests were not a clean build or an Electron test run.Live GitHub marketplace exchange, Entra/broker behavior, actual sleep/resume, and remote deployments were not exercised.
Remaining review items
client_idcontract against a live deployment and obtain security review of distributing the marketplace bearer to the shared process and connected remote server.Drafted with GitHub Copilot.