Skip to content

Commit 9ba4d2f

Browse files
authored
feat: wire shared MCP OAuth stores in unified binary with integration tests (#2160)
Create shared ConsentCodeStore (BFF) and OIDCStateStore (MCP) instances at startup and pass them to both the BFF consent handler and MCP OIDC handler. This enables the full consent-based OAuth 2.1 flow when running in unified binary mode. - Add oauthwiring package as public factory for MCP OAuth components (avoids importing internal/auth from cmd/meridian) - Add MCPOAuthEndpoints struct and WithMCPOAuthEndpoints ServerOption to mount /oauth/*, /.well-known/oauth-authorization-server, and /oauth/register on the gateway - Add wireMCPOAuth in wire_gateway.go with adapter types bridging gateway.ConsentCodeStore <-> mcpauth.ConsentCodeConsumer and mcpauth.OIDCStateStore <-> gateway.OIDCStatePeeker - Add Server.Handler() for test access to the HTTP mux - Add 6 integration tests covering full approve flow, deny flow, PKCE integrity, tenant isolation, metadata endpoint, and dynamic client registration Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 9df8ccf commit 9ba4d2f

6 files changed

Lines changed: 796 additions & 0 deletions

File tree

cmd/meridian/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ func setupAndStartGateway(ctx context.Context, infra *unifiedInfra, grpcPort, ht
329329
bffSigner, bffAuthOpts := wireBFFAuth(infra.conns.gormDB("identity"), logger)
330330
extraGWOpts = append(extraGWOpts, bffAuthOpts...)
331331

332+
mcpOAuthOpts, mcpOAuthCleanup := wireMCPOAuth(bffSigner, logger)
333+
extraGWOpts = append(extraGWOpts, mcpOAuthOpts...)
334+
if mcpOAuthCleanup != nil {
335+
defer mcpOAuthCleanup()
336+
}
337+
332338
baseDomain := env.GetEnvOrDefault("BASE_DOMAIN", "localhost")
333339
identityEmailOutboxRepo := email.NewPostgresOutboxRepository(infra.conns.gormDB("identity"))
334340
if regOpt := wireRegistration(infra.conns.gormDB("identity"), infra.conns.gormDB("tenant"), infra.loopback.rawConn, baseDomain, identityEmailOutboxRepo, logger); regOpt != nil {

0 commit comments

Comments
 (0)