From eea857ef719075e725ac98c8f0eea3e9a4af6946 Mon Sep 17 00:00:00 2001 From: Zhong Liang Ong Date: Tue, 2 Dec 2025 23:06:28 +0800 Subject: [PATCH 1/3] updated module references to Vungle/oauth-mcp-proxy Signed-off-by: Zhong Liang Ong --- cache.go | 2 +- config.go | 2 +- context_propagation_test.go | 2 +- examples/mark3labs/advanced/main.go | 4 ++-- examples/mark3labs/simple/main.go | 4 ++-- examples/official/advanced/main.go | 4 ++-- examples/official/simple/main.go | 4 ++-- go.mod | 2 +- integration_test.go | 2 +- mark3labs/middleware.go | 2 +- mark3labs/oauth.go | 2 +- mcp/oauth.go | 2 +- middleware.go | 2 +- oauth.go | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cache.go b/cache.go index 32759c2..48393cd 100644 --- a/cache.go +++ b/cache.go @@ -4,7 +4,7 @@ import ( "sync" "time" - "github.com/tuannvm/oauth-mcp-proxy/provider" + "github.com/Vungle/oauth-mcp-proxy/provider" ) // Re-export User from provider for backwards compatibility diff --git a/config.go b/config.go index d4e5071..ef67b30 100644 --- a/config.go +++ b/config.go @@ -3,7 +3,7 @@ package oauth import ( "fmt" - "github.com/tuannvm/oauth-mcp-proxy/provider" + "github.com/Vungle/oauth-mcp-proxy/provider" ) // Config holds OAuth configuration diff --git a/context_propagation_test.go b/context_propagation_test.go index cda909b..0b369fe 100644 --- a/context_propagation_test.go +++ b/context_propagation_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" + "github.com/Vungle/oauth-mcp-proxy/provider" "github.com/golang-jwt/jwt/v5" "github.com/mark3labs/mcp-go/mcp" - "github.com/tuannvm/oauth-mcp-proxy/provider" ) // TestContextPropagation validates Phase 2.1 context propagation fix diff --git a/examples/mark3labs/advanced/main.go b/examples/mark3labs/advanced/main.go index df5a949..b62ed85 100644 --- a/examples/mark3labs/advanced/main.go +++ b/examples/mark3labs/advanced/main.go @@ -7,10 +7,10 @@ import ( "net/http" "os" + oauth "github.com/Vungle/oauth-mcp-proxy" + "github.com/Vungle/oauth-mcp-proxy/mark3labs" "github.com/mark3labs/mcp-go/mcp" mcpserver "github.com/mark3labs/mcp-go/server" - oauth "github.com/tuannvm/oauth-mcp-proxy" - "github.com/tuannvm/oauth-mcp-proxy/mark3labs" ) func main() { diff --git a/examples/mark3labs/simple/main.go b/examples/mark3labs/simple/main.go index 3913115..3a20810 100644 --- a/examples/mark3labs/simple/main.go +++ b/examples/mark3labs/simple/main.go @@ -7,10 +7,10 @@ import ( "net/http" "os" + oauth "github.com/Vungle/oauth-mcp-proxy" + "github.com/Vungle/oauth-mcp-proxy/mark3labs" "github.com/mark3labs/mcp-go/mcp" mcpserver "github.com/mark3labs/mcp-go/server" - oauth "github.com/tuannvm/oauth-mcp-proxy" - "github.com/tuannvm/oauth-mcp-proxy/mark3labs" ) func main() { diff --git a/examples/official/advanced/main.go b/examples/official/advanced/main.go index 4d89ee4..01b3c44 100644 --- a/examples/official/advanced/main.go +++ b/examples/official/advanced/main.go @@ -8,9 +8,9 @@ import ( "os" "time" + oauth "github.com/Vungle/oauth-mcp-proxy" + mcpoauth "github.com/Vungle/oauth-mcp-proxy/mcp" "github.com/modelcontextprotocol/go-sdk/mcp" - oauth "github.com/tuannvm/oauth-mcp-proxy" - mcpoauth "github.com/tuannvm/oauth-mcp-proxy/mcp" ) func main() { diff --git a/examples/official/simple/main.go b/examples/official/simple/main.go index ea80496..f7a13b1 100644 --- a/examples/official/simple/main.go +++ b/examples/official/simple/main.go @@ -7,9 +7,9 @@ import ( "net/http" "os" + oauth "github.com/Vungle/oauth-mcp-proxy" + mcpoauth "github.com/Vungle/oauth-mcp-proxy/mcp" "github.com/modelcontextprotocol/go-sdk/mcp" - oauth "github.com/tuannvm/oauth-mcp-proxy" - mcpoauth "github.com/tuannvm/oauth-mcp-proxy/mcp" ) func main() { diff --git a/go.mod b/go.mod index 4b12be8..3e801e3 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tuannvm/oauth-mcp-proxy +module github.com/Vungle/oauth-mcp-proxy go 1.24.9 diff --git a/integration_test.go b/integration_test.go index 9079323..9129f12 100644 --- a/integration_test.go +++ b/integration_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" + "github.com/Vungle/oauth-mcp-proxy/provider" "github.com/golang-jwt/jwt/v5" "github.com/mark3labs/mcp-go/mcp" mcpserver "github.com/mark3labs/mcp-go/server" - "github.com/tuannvm/oauth-mcp-proxy/provider" ) // TestIntegration validates core architecture and integration. diff --git a/mark3labs/middleware.go b/mark3labs/middleware.go index 8c763fc..f620da0 100644 --- a/mark3labs/middleware.go +++ b/mark3labs/middleware.go @@ -4,9 +4,9 @@ import ( "context" "fmt" + oauth "github.com/Vungle/oauth-mcp-proxy" "github.com/mark3labs/mcp-go/mcp" "github.com/mark3labs/mcp-go/server" - oauth "github.com/tuannvm/oauth-mcp-proxy" ) // NewMiddleware creates an authentication middleware for mark3labs/mcp-go SDK. diff --git a/mark3labs/oauth.go b/mark3labs/oauth.go index 3a6320e..420a3fd 100644 --- a/mark3labs/oauth.go +++ b/mark3labs/oauth.go @@ -4,8 +4,8 @@ import ( "fmt" "net/http" + oauth "github.com/Vungle/oauth-mcp-proxy" mcpserver "github.com/mark3labs/mcp-go/server" - oauth "github.com/tuannvm/oauth-mcp-proxy" ) // WithOAuth returns a server option that enables OAuth authentication diff --git a/mcp/oauth.go b/mcp/oauth.go index 9a90911..34548ab 100644 --- a/mcp/oauth.go +++ b/mcp/oauth.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" + oauth "github.com/Vungle/oauth-mcp-proxy" "github.com/modelcontextprotocol/go-sdk/mcp" - oauth "github.com/tuannvm/oauth-mcp-proxy" ) // WithOAuth returns an OAuth-protected HTTP handler for the official diff --git a/middleware.go b/middleware.go index 3df55f1..b223f3a 100644 --- a/middleware.go +++ b/middleware.go @@ -9,9 +9,9 @@ import ( "strings" "time" + "github.com/Vungle/oauth-mcp-proxy/provider" "github.com/mark3labs/mcp-go/mcp" "github.com/mark3labs/mcp-go/server" - "github.com/tuannvm/oauth-mcp-proxy/provider" ) // Middleware returns an authentication middleware for MCP tools. diff --git a/oauth.go b/oauth.go index 027d96c..f8673c2 100644 --- a/oauth.go +++ b/oauth.go @@ -9,8 +9,8 @@ import ( "strings" "time" + "github.com/Vungle/oauth-mcp-proxy/provider" mcpserver "github.com/mark3labs/mcp-go/server" - "github.com/tuannvm/oauth-mcp-proxy/provider" ) // Server represents an OAuth authentication server instance. From 94057811fbae5f1a7cb6c0ee34d74e2d53e4f640 Mon Sep 17 00:00:00 2001 From: Zhong Liang Ong Date: Thu, 4 Dec 2025 10:37:25 +0800 Subject: [PATCH 2/3] updated to log every method Signed-off-by: Zhong Liang Ong --- oauth.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/oauth.go b/oauth.go index f8673c2..e0e72ea 100644 --- a/oauth.go +++ b/oauth.go @@ -90,14 +90,22 @@ func NewServer(cfg *Config) (*Server, error) { // Note: WithOAuth() calls this automatically. Only call directly if using // NewServer() for advanced use cases. func (s *Server) RegisterHandlers(mux *http.ServeMux) { - mux.HandleFunc("/.well-known/oauth-authorization-server", s.handler.HandleAuthorizationServerMetadata) - mux.HandleFunc("/.well-known/oauth-protected-resource", s.handler.HandleProtectedResourceMetadata) - mux.HandleFunc("/.well-known/jwks.json", s.handler.HandleJWKS) - mux.HandleFunc("/oauth/authorize", s.handler.HandleAuthorize) - mux.HandleFunc("/oauth/callback", s.handler.HandleCallback) - mux.HandleFunc("/oauth/token", s.handler.HandleToken) - mux.HandleFunc("/oauth/register", s.handler.HandleRegister) - mux.HandleFunc("/.well-known/openid-configuration", s.handler.HandleOIDCDiscovery) + mux.HandleFunc("/.well-known/oauth-authorization-server", s.LogRequestMiddleware(s.handler.HandleAuthorizationServerMetadata)) + mux.HandleFunc("/.well-known/oauth-protected-resource", s.LogRequestMiddleware(s.handler.HandleProtectedResourceMetadata)) + mux.HandleFunc("/.well-known/jwks.json", s.LogRequestMiddleware(s.handler.HandleJWKS)) + mux.HandleFunc("/oauth/authorize", s.LogRequestMiddleware(s.handler.HandleAuthorize)) + mux.HandleFunc("/oauth/callback", s.LogRequestMiddleware(s.handler.HandleCallback)) + mux.HandleFunc("/oauth/token", s.LogRequestMiddleware(s.handler.HandleToken)) + mux.HandleFunc("/oauth/register", s.LogRequestMiddleware(s.handler.HandleRegister)) + mux.HandleFunc("/.well-known/openid-configuration", s.LogRequestMiddleware(s.handler.HandleOIDCDiscovery)) +} + +// LogRequestMiddleware creates a server-level authentication hook for all MCP requests. +func (s *Server) LogRequestMiddleware(next func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + defer s.logger.Info(fmt.Sprintf("Log Request:\nRequest: %+v\nResponse: %+v\n", r, w)) + next(w, r) + } } // ValidateTokenCached validates a token with caching support. From acd38c076ae85cf955ac0ec180cd57359af04e82 Mon Sep 17 00:00:00 2001 From: Zhong Liang Ong Date: Thu, 4 Dec 2025 12:51:18 +0800 Subject: [PATCH 3/3] update with dumprequest Signed-off-by: Zhong Liang Ong --- oauth.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oauth.go b/oauth.go index e0e72ea..cf042ce 100644 --- a/oauth.go +++ b/oauth.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/http/httputil" "strings" "time" @@ -103,7 +104,9 @@ func (s *Server) RegisterHandlers(mux *http.ServeMux) { // LogRequestMiddleware creates a server-level authentication hook for all MCP requests. func (s *Server) LogRequestMiddleware(next func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { - defer s.logger.Info(fmt.Sprintf("Log Request:\nRequest: %+v\nResponse: %+v\n", r, w)) + // leave error unhandled since it's a debug print + req, _ := httputil.DumpRequest(r, true) + s.logger.Info(fmt.Sprintf("\nLog Request dumped = %q\n", req)) next(w, r) } }