No description
  • Go 97.9%
  • Dockerfile 1.5%
  • Makefile 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Sundeep 20b5cb9b12
Guard authorization server metadata fetches (#11)
* Guard authorization server metadata fetches

* Allow insecure local OAuth by opt-in
2026-08-13 11:45:43 -07:00
.github Pin the Buildx setup action (#10) 2026-08-13 09:59:23 -07:00
.golangci.yml init 2025-09-24 19:46:24 -07:00
dcr.go Make the list of allowed URIs configurable (#7) 2026-06-08 14:15:46 -07:00
dcr_test.go Make the list of allowed URIs configurable (#7) 2026-06-08 14:15:46 -07:00
discovery.go Guard authorization server metadata fetches (#11) 2026-08-13 11:45:43 -07:00
discovery_test.go Guard authorization server metadata fetches (#11) 2026-08-13 11:45:43 -07:00
Dockerfile init 2025-09-24 19:46:24 -07:00
go.mod init 2025-09-24 19:46:24 -07:00
LICENSE Initial commit 2025-09-24 19:41:50 -07:00
log.go bugfix: OAuth Discovery Robustness, Logging, and Test Coverage (#1) 2025-10-15 10:38:32 -07:00
Makefile init 2025-09-24 19:46:24 -07:00
README.md Guard authorization server metadata fetches (#11) 2026-08-13 11:45:43 -07:00
ssrf.go Guard authorization server metadata fetches (#11) 2026-08-13 11:45:43 -07:00
testutil.go bugfix: OAuth Discovery Robustness, Logging, and Test Coverage (#1) 2025-10-15 10:38:32 -07:00
types.go init 2025-09-24 19:46:24 -07:00
www_authenticate.go bugfix: OAuth Discovery Robustness, Logging, and Test Coverage (#1) 2025-10-15 10:38:32 -07:00
www_authenticate_test.go bugfix: OAuth Discovery Robustness, Logging, and Test Coverage (#1) 2025-10-15 10:38:32 -07:00

MCP Gateway OAuth Helpers

Library containing OAuth Dynamic Client Registration (DCR) functionality for MCP servers.

Note: This code was extracted from MCP Gateway PR: https://github.com/docker/mcp-gateway/pull/148

Purpose

This library provides the core OAuth/DCR functions for MCP Gateway:

  • OAuth Discovery: Discover OAuth requirements from MCP servers (RFC 9728 + 8414)
  • Dynamic Client Registration: Register OAuth clients automatically (RFC 7591)
  • WWW-Authenticate Parsing: Parse OAuth challenge headers

Local development

OAuth discovery allows only public HTTPS authorization servers by default. It rejects localhost, private, link-local, and reserved destinations before dialing, including redirect targets.

For local development with an HTTP or private-network OAuth provider, set DOCKER_MCP_ALLOW_INSECURE_REMOTE_URLS=1. This disables the authorization server network guard and HTTPS requirement, so it must not be enabled with untrusted MCP servers.

Configuring redirect URI validation

By default DCR only accepts redirect URI hosts for localhost, mcp.docker.com, and mcp-stage.docker.com. Use PerformDCRWithConfig to provide a custom allowlist:

allowedHosts := append(oauth.DefaultAllowedRedirectURIHosts(), "oauth.example.com")
creds, err := oauth.PerformDCRWithConfig(ctx, discovery, "my-server", oauth.DCRConfig{
    RedirectURI:             "https://oauth.example.com/callback",
    AllowedRedirectURIHosts: allowedHosts,
})