feat(teams): per-user OAuth connect flow (Path B) broker connector (spec 074, MCP-1038)#602
Open
Dumbris wants to merge 1 commit into
Open
feat(teams): per-user OAuth connect flow (Path B) broker connector (spec 074, MCP-1038)#602Dumbris wants to merge 1 commit into
Dumbris wants to merge 1 commit into
Conversation
…pec 074, MCP-1038) Adds internal/teams/broker.OAuthConnector implementing Path B of the upstream token-brokering spec: a per-user authorization-code + PKCE connect flow against an upstream AS that does not support token exchange. - BuildAuthorizationURL: PKCE (S256) verifier/challenge + opaque per-user state, tracked in-memory with a TTL; requires explicit AS consent (confused-deputy avoidance, FR-011). - Complete: validates state (unknown/expired/one-time), exchanges the code via the bound verifier, stores the per-user credential encrypted with ObtainedVia=connect_flow (FR-010). - Deny: clears the pending flow, stores nothing (denied consent). - Refresh: transparent refresh_token grant, preserving a non-rotated refresh token (FR-012). Config: AuthBrokerConfig gains authorization_endpoint, required for the oauth_connect mode. TDD: PKCE URL build + uniqueness, PKCE roundtrip, invalid/expired/one-time state, token-endpoint error, denied consent stores nothing, refresh path. Reuses oauth.GenerateServerKey for the store key; server edition only. Related #1038 Co-Authored-By: Paperclip <noreply@paperclip.ing>
Deploying mcpproxy-docs with
|
| Latest commit: |
093093b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f43fc44c.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://074-t5-oauth-connector.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 26968177071 --repo smart-mcp-proxy/mcpproxy-go
|
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.
Spec 074 · T5 — OAuthConnector (Path B)
Implements the per-user OAuth connect flow for upstreams whose AS does not support token exchange but does standard authorization-code OAuth. This is the connector engine + handlers; REST endpoints are T8 ([MCP-1041]).
Builds on T1 ([MCP-1034], CredentialStore #587) and T2 ([MCP-1035], auth_broker config #588), both merged.
What's added
internal/teams/broker/OAuthConnector(server edition only):BuildAuthorizationURL(userID)— generates a PKCE (S256) verifier/challenge and an opaque per-userstate, tracks the pending flow in-memory with a TTL, and returns the upstream authorize URL. Explicit AS consent + unguessable state = confused-deputy avoidance (FR-011).Complete(ctx, state, code)— validatesstate(rejects unknown / expired / already-used), exchanges the code via the bound verifier at the token endpoint, and persists the per-user credential encrypted withObtainedVia=connect_flow(FR-010). State is single-use.Deny(state, reason)— denied/failed callback clears the pending flow and stores nothing.Refresh(ctx, userID)— transparentrefresh_tokengrant; preserves a non-rotated refresh token (FR-012).Store key uses the existing
oauth.GenerateServerKey(name,url)scheme. The HTTP token-exchange pattern mirrors the mergedinternal/teams/auth/oauth_providers.go.Config
config.AuthBrokerConfiggainsauthorization_endpoint, now required whenmode: oauth_connect(the connect flow needs the upstream authorize URL).token_exchange/entra_oboare unaffected.Tests (TDD — test-first, watched RED → GREEN)
oauth_connector_test.go: PKCE URL build + per-flow uniqueness, full PKCE roundtrip (token endpoint receives a verifier whose S256 equals the advertised challenge), invalid/expired/one-timestate, token-endpoint error → nothing stored, denied consent → nothing stored, refresh path (incl. preserve-on-no-rotation and no-refresh-token error), constructor validation. Plusauth_broker_test.gofor the new config requirement.Verification
go test -tags server -race ./internal/teams/broker/ ./internal/config/✅go test -tags server ./internal/teams/...✅go build -tags server ./cmd/mcpproxy✅ andgo build ./cmd/mcpproxy(personal unaffected) ✅gofmt -lclean,go vet -tags servercleanDocs note
The whole
auth_brokerblock is still being assembled across spec-074 tasks and currently has no user-facing docs (T1/T2 merged the config block + store with godoc only; the user surface — REST/CLI — lands in T8/T9). Following that precedent, end-user docs for the connect flow belong with the surfacing tasks; the new config key carries thorough godoc here.Related #1038