Proxy MCP OAuth callbacks on behalf of connected squadrons#25
Open
mlund01 wants to merge 1 commit into
Open
Conversation
Command center now hosts a public, unauthenticated OAuth callback endpoint
that IdPs can redirect to. When a squadron kicks off an MCP login it
reserves a flow keyed by the OAuth `state` value; the callback handler
looks up the owning squadron and forwards the code/state back over the
WS bridge. Motivation: squadrons on remote hosts can't bind a loopback
callback, and some IdPs require pre-registered HTTPS redirect URIs.
New endpoints:
- GET /oauth/callback (on outerMux, no auth — IdPs don't carry session
cookies; security comes from the unguessable single-use state value).
- POST /api/instances/{id}/mcp/{name}/oauth/start — browser-initiated
MCP login. Forwards StartMCPLogin to squadron, returns the authorization
URL for the browser to window.open.
- GET /api/instances/{id}/notifications — per-instance SSE stream of
ephemeral events. Currently delivers oauth_completed / oauth_failed
notifications; structured to accept future event types.
Hub additions:
- PendingFlows (internal/oauth/flows.go) — state→{instanceID, mcpName}
store with 10-minute TTL and tests.
- Notifications (internal/hub/notifications.go) — per-instance fan-out
with no buffering (ephemeral toasts only).
- Connection dispatch handles inbound OAuthRegisterFlow from squadrons.
Frontend:
- api.startMcpOauth wraps the start endpoint.
- subscribeInstanceNotifications SSE helper.
- useInstanceNotifications hook mounted in AppLayout surfaces toasts via
Sonner on oauth_completed / oauth_failed.
- Tools page gains a Connect button on MCP rows.
TEMP: go.mod has a local replace pointing at ../squadron-wire for the
new protocol message types. Revert + bump once squadron-wire tags a new
version (see sibling PR).
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
GET /oauth/callbackendpoint lets IdPs redirect to command center. The handler looks up the owning squadron via the OAuthstatevalue and forwards the code/state over the WS bridge.POST /api/instances/{id}/mcp/{name}/oauth/startfor browser-initiated MCP logins. Returns the authorization URL for the browser towindow.open.GET /api/instances/{id}/notificationsSSE stream surfaces per-instance ephemeral events. Toasts fire onoauth_completed/oauth_failedvia auseInstanceNotificationshook mounted inAppLayout.Paired with:
Multi-tenancy
The
/oauth/callbackendpoint is shared across all connected squadrons — routing is bystate(cryptographically random, per-flow). No per-squadron URL needed, so DCR-registered redirect URIs stay fixed.TEMP notice
go.modhas a localreplacefor squadron-wire until the sibling PR merges and a tag is cut. Will be removed + bumped before merge.Test plan
go test ./...green (newinternal/oauthsuite + existing suites)