Skip to content

Add authentication middleware for SSE/HTTP with multi-user support#377

Open
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Pnkcaht:feat/sse-bearer-token-auth
Open

Add authentication middleware for SSE/HTTP with multi-user support#377
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Pnkcaht:feat/sse-bearer-token-auth

Conversation

@Pnkcaht
Copy link
Copy Markdown
Contributor

@Pnkcaht Pnkcaht commented Feb 3, 2026

What I Did

  • Implemented basic Bearer token authentication for the MCP Gateway.
  • Added multi-user token support.
  • Logged initialization parameters for debugging (logInitializeParams).
  • Updated SSE/HTTP/Streaming servers to validate tokens before serving requests.
  • Ensured DCO compliance in commit.

Related Issue

Closes: #370

Previously, Docker MCP worked fine locally but was insecure in shared or cloud environments.
This commit introduces native token-based authentication to allow secure, centralized MCP deployments.

Before / After

Before:

  • MCP server assumed a "trust everything" model.
  • Anyone who could reach the port could execute commands.
  • Custom middleman gateway required for token validation.

After:

  • SSE/HTTP/Streaming endpoints now validate Bearer tokens.
  • Single-user and multi-user tokens supported.
  • Initialization logs now structured and include client identity info.
  • Secure access possible without VPN or external proxies.

Diagram (Mermaid)

flowchart TD
    Client -->|HTTP/SSE request w/ Bearer| MCPServer
    MCPServer -->|Check token| AuthMiddleware
    AuthMiddleware -->|Valid token| Handler
    AuthMiddleware -->|Invalid token| Unauthorized
    Handler -->|Respond| Client
Loading

Notes / Future Work

  • Middleware is applied for authentication, but SSE/HTTP/Streaming servers may need additional fine-tuning to ensure full coverage.
  • Exposing a CLI parameter --token to allow passing a secret key at startup is still pending.
  • This commit fully closes the related issue for secure multi-user access.
  • Future improvements:
    • Apply authentication middleware consistently across all transport types.
    • Expose --token and support configuration via environment variables for easier deployment.

Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
@Pnkcaht Pnkcaht requested a review from a team as a code owner February 3, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Native Token Authorization for Remote/SSE Deployments

1 participant