Add persistent browser auth to connector canvas

Replace Azure CLI-only authentication with InteractiveBrowserCredential, protected sign-in lifecycle endpoints, and subscription refresh after sign-in. Persist the Azure Identity cache securely across extension reloads and align connector restart guidance with the GitHub Copilot app.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alex Yang (DevDiv)
2026-07-20 13:04:18 -07:00
parent 9ae2bdc8b7
commit 2f258c7226
16 changed files with 945 additions and 258 deletions
+19 -12
View File
@@ -6,14 +6,16 @@ session. Search by name or category, sign in to a connector, then restart the
session to make its tools available to the agent.
> The canvas talks to public Azure Resource Manager (`management.azure.com`)
> using the signed-in Azure CLI account. The extension does not register its own
> Entra application or persist Azure credentials.
> using an interactive Microsoft Entra browser sign-in. It does not register its
> own Entra application. Azure Identity persists the account session in the
> operating system's encrypted credential store.
## Prerequisites
- **GitHub Copilot CLI** (the host that loads canvas extensions).
- **Azure CLI**, signed in with `az login`. The extension asks Azure CLI for a
short-lived ARM access token and refreshes it through the same broker.
- A browser for Microsoft Entra sign-in. The extension prompts when Azure
authentication is required and restores the encrypted Azure Identity session
after extension or Copilot CLI restarts.
- **An Azure subscription with a Connector Namespace** — resource type
`Microsoft.Web/connectorGateways` (API version `2026-05-01-preview`). This is
a preview resource provider; you must have access to it for the catalog to
@@ -41,14 +43,15 @@ The destination **scope** is chosen at install time:
## Usage
1. Open the **MCP Connectors** canvas from Copilot CLI.
2. The canvas loads subscriptions from your signed-in Azure CLI account. Pick an
2. If prompted, choose **Sign in** and complete Microsoft Entra authentication
in the browser. The canvas reloads your subscriptions automatically. Pick an
Azure **subscription** and a **Connector Namespace**. The choice is saved for
future sessions (change it any time via **Change namespace**).
3. Browse or filter the connector catalog, then **Connect**. A browser tab
opens for Microsoft sign-in; complete it and the canvas updates on its own.
4. Connected connectors move into **My MCPs**. Use **Sandbox** on a tile to open
that server directly in the namespace MCP playground.
5. Restart the Copilot CLI session so the agent can load the connected tools.
5. Restart the GitHub Copilot app so the agent can load the connected tools.
The extension registers the native `connector_namespaces_open_playground` tool,
so GitHub Copilot can open a named connector from **My MCPs** without installing
@@ -59,9 +62,11 @@ an additional Agent Skill.
- `extension.mjs` — entry point; declares the canvas, `open_sandbox` action, and
native `connector_namespaces_open_playground` tool.
- `server.mjs` — a loopback HTTP server (bound to `127.0.0.1` only) that serves
the canvas UI and the JSON/OAuth endpoints the iframe calls.
- `armClient.mjs`thin ARM client (token brokered by Azure CLI, public ARM
base only, SSRF-guarded path segments).
the canvas UI and the JSON/authentication endpoints the iframe calls.
- `auth.mjs``InteractiveBrowserCredential` broker for sign-in lifecycle,
cancellation, encrypted token-cache persistence, and ARM token refresh.
- `armClient.mjs` — thin ARM client (public ARM base only, SSRF-guarded path
segments).
- `catalog.mjs` — fetches and curates the connector list for a namespace.
- `install.mjs` — the connect/install pipeline (managed-API connection, consent,
rollback on cancel, and native HTTPS MCP config registration).
@@ -71,9 +76,11 @@ an additional Agent Skill.
## Privacy & security
- ARM tokens come from `az account get-access-token`, stay in process memory,
and are never logged or written by the extension. Azure CLI owns sign-in and
credential storage.
- ARM tokens come from `@azure/identity`'s `InteractiveBrowserCredential` and
are never logged. Azure Identity stores its refreshable account cache through
the operating system's encrypted credential store. A non-secret account
locator is saved with user-only permissions so a new process can select that
cache entry; the extension never writes raw tokens to its artifact files.
- All servers bind to loopback (`127.0.0.1`) and are never exposed externally.
- ARM requests go only to `https://management.azure.com/`; path segments are
validated to prevent SSRF-style host smuggling.