Skip to content

Commit b83c7fa

Browse files
shams858Shamsul Arefincrivetimihaivk-playgroundclaude
authored
feat: Experimental Oauth 2.0 support in gateway (#768)
* Oauth 2.1 design Signed-off-by: Shamsul Arefin <[email protected]> * oauth 2.0 design Signed-off-by: Shamsul Arefin <[email protected]> * Support for oauth auth type in gateway Signed-off-by: Shamsul Arefin <[email protected]> * Decrypt client secret Signed-off-by: Shamsul Arefin <[email protected]> * authorization code flow, token storage, tool fetching, tool calling with Oauth2.0 Signed-off-by: Shamsul Arefin <[email protected]> * test fixes Signed-off-by: Shamsul Arefin <[email protected]> * 256 fuzz testing (#760) * Implement comprehensive fuzz testing automation (#256) - Add property-based testing with Hypothesis for JSON-RPC, JSONPath, and schema validation - Add coverage-guided fuzzing with Atheris for deep code path exploration - Add API endpoint fuzzing with Schemathesis for contract validation - Add security-focused testing for vulnerability discovery (SQL injection, XSS, etc.) - Add complete Makefile automation with fuzz-all, fuzz-quick, fuzz-extended targets - Add optional [fuzz] dependency group in pyproject.toml for clean installation - Add comprehensive reporting with JSON/Markdown outputs and executive summaries - Add complete developer documentation with examples and troubleshooting guides - Exclude fuzz tests from main test suite to prevent auth failures - Found multiple real bugs in JSON-RPC validation during development Signed-off-by: Mihai Criveti <[email protected]> * Update fuzz testing Signed-off-by: Mihai Criveti <[email protected]> * Update fuzz testing Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]> * 344 cors security headers (#761) * Update CORS Signed-off-by: Mihai Criveti <[email protected]> * Update CORS Signed-off-by: Mihai Criveti <[email protected]> * Update CORS ADRs Signed-off-by: Mihai Criveti <[email protected]> * Update CORS Signed-off-by: Mihai Criveti <[email protected]> * Update CORS Signed-off-by: Mihai Criveti <[email protected]> * Fix compose Signed-off-by: Mihai Criveti <[email protected]> * Update helm chart Signed-off-by: Mihai Criveti <[email protected]> * Update CORS docs Signed-off-by: Mihai Criveti <[email protected]> * Update test Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]> Signed-off-by: Shamsul Arefin <[email protected]> * feat: Bulk Import Tools modal wiring #737 (#739) * feat: Bulk Import Tools modal wiring and backend implementation - Add modal UI in admin.html with bulk import button and dialog - Implement modal open/close/ESC functionality in admin.js - Add POST /admin/tools/import endpoint with rate limiting - Support both JSON textarea and file upload inputs - Validate JSON structure and enforce 200 tool limit - Return detailed success/failure information per tool - Include loading states and comprehensive error handling Refs #737 Signed-off-by: Mihai Criveti <[email protected]> * fix: Remove duplicate admin_import_tools function and fix HTML formatting - Remove duplicate admin_import_tools function definition - Fix HTML placeholder attribute to use double quotes - Add missing closing div tag - Fix flake8 blank line issues Signed-off-by: Mihai Criveti <[email protected]> * feat: Complete bulk import backend with file upload support and enhanced docs - Add file upload support to admin_import_tools endpoint - Fix response format to match frontend expectations - Add UI usage documentation with modal instructions - Update API docs to show all three input methods - Enhance bulk import guide with UI and API examples Backend improvements: - Support tools_file form field for JSON file uploads - Proper file content parsing with error handling - Response includes imported/failed counts and details - Frontend-compatible response format for UI display Signed-off-by: Mihai Criveti <[email protected]> * Bulk import Signed-off-by: Mihai Criveti <[email protected]> * fix: Remove conflicting inline script and fix bulk import functionality - Remove conflicting inline JavaScript that was preventing form submission - Fix indentation in setupBulkImportModal function - Ensure bulk import modal uses proper admin.js implementation - Restore proper form submission handling for bulk import This fixes the issue where bulk import appeared to do nothing. Signed-off-by: Mihai Criveti <[email protected]> * fix: Integrate bulk import setup with main initialization - Add setupBulkImportModal() to main initialization sequence - Remove duplicate DOMContentLoaded listener - Ensure bulk import doesn't interfere with other tab functionality Signed-off-by: Mihai Criveti <[email protected]> * fix: JavaScript formatting issues in bulk import modal - Fix multiline querySelector formatting - Fix multiline Error constructor formatting - Ensure prettier compliance for web linting Signed-off-by: Mihai Criveti <[email protected]> * debug: Temporarily disable bulk import setup to test tabs Signed-off-by: Mihai Criveti <[email protected]> * fix: Remove duplicate setupFormValidation call and delay bulk import setup - Remove duplicate setupFormValidation() call that could cause conflicts - Use setTimeout to delay bulk import modal setup after other initialization - Add better null safety to form element queries - This should fix tab switching issues Signed-off-by: Mihai Criveti <[email protected]> * fix: Restore proper initialization sequence for tab functionality - Remove setTimeout delay for bulk import setup - Keep bulk import setup in main initialization but with error handling - Ensure tab navigation isn't affected by bulk import modal setup Signed-off-by: Mihai Criveti <[email protected]> * fix: Correct HTML structure and restore tab navigation - Move bulk import modal to correct location after tools panel - Remove extra closing div that was breaking HTML structure - Ensure proper page-level modal placement - Restore tab navigation functionality for all tabs This fixes the broken Global Resources, Prompts, Gateways, Roots, and Metrics tabs. Signed-off-by: Mihai Criveti <[email protected]> * feat: Add configurable bulk import settings Configuration additions: - MCPGATEWAY_BULK_IMPORT_MAX_TOOLS (default: 200) - MCPGATEWAY_BULK_IMPORT_RATE_LIMIT (default: 10) Implementation: - config.py: Add new settings with defaults - admin.py: Use configurable rate limit and batch size - .env.example: Document all bulk import environment variables - admin.html: Use dynamic max tools value in UI text - CLAUDE.md: Document configuration options for developers - docs: Update bulk import guide with configuration details This makes bulk import fully configurable for different deployment scenarios. Signed-off-by: Mihai Criveti <[email protected]> * Update docs Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]> Signed-off-by: Shamsul Arefin <[email protected]> * Implemented configuration export (#764) Signed-off-by: Mihai Criveti <[email protected]> Signed-off-by: Shamsul Arefin <[email protected]> * cleanup Signed-off-by: Shamsul Arefin <[email protected]> * cleanup Signed-off-by: Shamsul Arefin <[email protected]> * fixes Signed-off-by: Shamsul Arefin <[email protected]> * ruff fixes Signed-off-by: Shamsul Arefin <[email protected]> * fix flake8 errors Signed-off-by: Shamsul Arefin <[email protected]> * fix eslint errors Signed-off-by: Shamsul Arefin <[email protected]> * aiohttp added in the main dependencies section of pyproject.toml Signed-off-by: Shamsul Arefin <[email protected]> * Review, rebase and lint Signed-off-by: Mihai Criveti <[email protected]> * Fix Alembic multiple heads issue Create merge migration to resolve parallel migration chains: - Main branch migrations (34492f99a0c4) - OAuth branch migrations (add_oauth_tokens_table) This resolves CI/CD test failures caused by Alembic not knowing which migration head to follow during 'alembic upgrade head'. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> * Fix Alembic migration chain - remove merge migration hack - Remove unnecessary merge migration file (813b45a70b53) - Fix OAuth config migration to follow proper chain (f8c9d3e2a1b4 → 34492f99a0c4) - OAuth tokens migration already correctly follows (add_oauth_tokens_table → f8c9d3e2a1b4) - Now single migration head without parallel branches This eliminates the 'Multiple heads are present' error in CI/CD tests by ensuring migrations follow a linear chain instead of creating parallel migration branches that need artificial merge migrations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> * Review, rebase and lint Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Shamsul Arefin <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Shamsul Arefin <[email protected]> Co-authored-by: Mihai Criveti <[email protected]> Co-authored-by: VK <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent eea6292 commit b83c7fa

21 files changed

+4039
-229
lines changed

.env.example

Lines changed: 155 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,41 @@ CACHE_TYPE=memory
1818
# CACHE_TYPE=redis
1919
# REDIS_URL=redis://localhost:6379/0
2020

21+
22+
# Maximum number of times to boot redis connection for cold start
23+
REDIS_MAX_RETRIES=3
24+
25+
# Interval time for next retry of redis connection
26+
REDIS_RETRY_INTERVAL_MS=2000
27+
28+
#####################################
29+
# Protocol Settings
30+
#####################################
31+
32+
# MCP protocol version supported by this gateway
33+
PROTOCOL_VERSION=2025-03-26
34+
35+
#####################################
36+
# Authentication
37+
#####################################
38+
39+
# Admin UI basic-auth credentials
40+
# PRODUCTION: Change these to strong, unique values!
2141
# Authentication Configuration
2242
JWT_SECRET_KEY=my-test-key
2343
JWT_ALGORITHM=HS256
2444
BASIC_AUTH_USER=admin
2545
BASIC_AUTH_PASSWORD=changeme
2646
AUTH_REQUIRED=true
47+
48+
# Secret used to sign JWTs (use long random value in prod)
49+
# PRODUCTION: Use a strong, random secret (minimum 32 characters)
50+
JWT_SECRET_KEY=my-test-key
51+
52+
# Algorithm used to sign JWTs (e.g., HS256)
53+
JWT_ALGORITHM=HS256
54+
55+
# Expiry time for generated JWT tokens (in minutes; e.g. 7 days)
2756
TOKEN_EXPIRY=10080
2857
REQUIRE_TOKEN_EXPIRATION=false
2958

@@ -32,10 +61,134 @@ MCP_CLIENT_AUTH_ENABLED=true
3261
TRUST_PROXY_AUTH=false
3362
PROXY_USER_HEADER=X-Authenticated-User
3463

64+
# Used to derive an AES encryption key for secure auth storage
65+
# Must be a non-empty string (e.g. passphrase or random secret)
66+
AUTH_ENCRYPTION_SECRET=my-test-salt
67+
68+
#####################################
69+
# Admin UI and API Toggles
70+
#####################################
71+
72+
# Enable the visual Admin UI (true/false)
73+
# PRODUCTION: Set to false for security
74+
MCPGATEWAY_UI_ENABLED=true
75+
76+
# Enable the Admin API endpoints (true/false)
77+
# PRODUCTION: Set to false for security
78+
3579
# UI/Admin Feature Flags
3680
MCPGATEWAY_UI_ENABLED=true
3781
MCPGATEWAY_ADMIN_API_ENABLED=true
3882
MCPGATEWAY_BULK_IMPORT_ENABLED=true
83+
84+
# Maximum number of tools allowed per bulk import request
85+
MCPGATEWAY_BULK_IMPORT_MAX_TOOLS=200
86+
87+
# Rate limiting for bulk import endpoint (requests per minute)
88+
MCPGATEWAY_BULK_IMPORT_RATE_LIMIT=10
89+
90+
#####################################
91+
# Header Passthrough Configuration
92+
#####################################
93+
94+
# SECURITY WARNING: Header passthrough is disabled by default for security.
95+
# Only enable if you understand the security implications and have reviewed
96+
# which headers should be passed through to backing MCP servers.
97+
# ENABLE_HEADER_PASSTHROUGH=false
98+
99+
# Default headers to pass through (when feature is enabled)
100+
# JSON array format recommended: ["X-Tenant-Id", "X-Trace-Id"]
101+
# Comma-separated also supported: X-Tenant-Id,X-Trace-Id
102+
# NOTE: Authorization header removed from defaults for security
103+
# DEFAULT_PASSTHROUGH_HEADERS=["X-Tenant-Id", "X-Trace-Id"]
104+
105+
#####################################
106+
# Security and CORS
107+
#####################################
108+
109+
# Skip TLS certificate checks for upstream requests (not recommended in prod)
110+
SKIP_SSL_VERIFY=false
111+
112+
# CORS origin allowlist (use JSON array of URLs)
113+
# Example: ["http://localhost:3000"]
114+
# Do not quote this value. Start with [] to ensure it's valid JSON.
115+
ALLOWED_ORIGINS='["http://localhost", "http://localhost:4444"]'
116+
117+
# Enable CORS handling in the gateway
118+
CORS_ENABLED=true
119+
120+
# CORS allow credentials (true/false)
121+
CORS_ALLOW_CREDENTIALS=true
122+
123+
# Environment setting (development/production) - affects security defaults
124+
# development: Auto-configures CORS for localhost:3000, localhost:8080, etc.
125+
# production: Uses APP_DOMAIN for HTTPS origins, enforces secure cookies
126+
ENVIRONMENT=development
127+
128+
# Domain configuration for production CORS origins
129+
# In production, automatically creates origins: https://APP_DOMAIN, https://app.APP_DOMAIN, https://admin.APP_DOMAIN
130+
# For production: set to your actual domain (e.g., mycompany.com)
131+
APP_DOMAIN=localhost
132+
133+
# Security settings for cookies
134+
# production: Automatically enables secure cookies regardless of this setting
135+
# development: Set to false for HTTP development, true for HTTPS
136+
SECURE_COOKIES=true
137+
138+
# Cookie SameSite attribute for CSRF protection
139+
# strict: Maximum security, may break some OAuth flows
140+
# lax: Good balance of security and compatibility (recommended)
141+
# none: Requires Secure=true, allows cross-site usage
142+
COOKIE_SAMESITE=lax
143+
144+
#####################################
145+
# Security Headers Configuration
146+
#####################################
147+
148+
# Enable security headers middleware (true/false)
149+
SECURITY_HEADERS_ENABLED=true
150+
151+
# X-Frame-Options setting (DENY, SAMEORIGIN, or ALLOW-FROM uri)
152+
# DENY: Prevents all iframe embedding (recommended for security)
153+
# SAMEORIGIN: Allows embedding from same domain only
154+
# To disable: Set to empty string X_FRAME_OPTIONS=""
155+
X_FRAME_OPTIONS=DENY
156+
157+
# Other security headers (true/false)
158+
X_CONTENT_TYPE_OPTIONS_ENABLED=true
159+
X_XSS_PROTECTION_ENABLED=true
160+
X_DOWNLOAD_OPTIONS_ENABLED=true
161+
162+
# HSTS (HTTP Strict Transport Security) settings
163+
HSTS_ENABLED=true
164+
# HSTS max age in seconds (31536000 = 1 year)
165+
HSTS_MAX_AGE=31536000
166+
HSTS_INCLUDE_SUBDOMAINS=true
167+
168+
# Remove server identification headers (true/false)
169+
REMOVE_SERVER_HEADERS=true
170+
171+
# Enable HTTP Basic Auth for docs endpoints (in addition to Bearer token auth)
172+
# Uses the same credentials as BASIC_AUTH_USER and BASIC_AUTH_PASSWORD
173+
DOCS_ALLOW_BASIC_AUTH=false
174+
175+
#####################################
176+
# Retry Config for HTTP Requests
177+
#####################################
178+
179+
RETRY_MAX_ATTEMPTS=3
180+
# seconds
181+
RETRY_BASE_DELAY=1.0
182+
# seconds
183+
RETRY_MAX_DELAY=60.0
184+
# fraction of delay
185+
RETRY_JITTER_MAX=0.5
186+
187+
#####################################
188+
# Logging
189+
#####################################
190+
191+
# Logging verbosity level: DEBUG, INFO, WARNING, ERROR, CRITICAL
39192
MCPGATEWAY_BULK_IMPORT_MAX_TOOLS=200
40193
MCPGATEWAY_BULK_IMPORT_RATE_LIMIT=10
41194

@@ -132,8 +285,8 @@ WELL_KNOWN_SECURITY_TXT=""
132285
# Example: {"ai.txt": "AI Usage: This service uses AI for tool orchestration...", "dnt-policy.txt": "We respect DNT headers..."}
133286
WELL_KNOWN_CUSTOM_FILES="{}"
134287

135-
# Cache control for well-known files (seconds)
136-
WELL_KNOWN_CACHE_MAX_AGE=3600 # 1 hour
288+
# Cache control for well-known files (seconds) - 3600 = 1 hour
289+
WELL_KNOWN_CACHE_MAX_AGE=3600
137290

138291
#####################################
139292
# Well-Known URI Examples

0 commit comments

Comments
 (0)