Skip to content

Fix/multi header auth 526#691

Merged
crivetimihai merged 8 commits intoIBM:mainfrom
manavgup:fix/multi-header-auth-526
Aug 9, 2025
Merged

Fix/multi header auth 526#691
crivetimihai merged 8 commits intoIBM:mainfrom
manavgup:fix/multi-header-auth-526

Conversation

@manavgup
Copy link
Copy Markdown
Collaborator

@manavgup manavgup commented Aug 9, 2025

closes #526

Modified Files (6):

  1. mcpgateway/schemas.py
    - Updated validation logic for multi-header support
    - Added edge case handling (duplicate keys, header validation, limits)
    - Maintains backward compatibility
  2. mcpgateway/admin.py
    - Updated admin_add_gateway and admin_edit_gateway functions
    - Added JSON parsing for auth_headers field
    - Added passthrough headers handling
  3. mcpgateway/static/admin.js
    - Added multi-header management functions
    - Added validation and edge case handling
    - Added duplicate key detection
  4. mcpgateway/templates/admin.html
    - Replaced single header inputs with dynamic multi-header interface
    - Added containers and hidden JSON fields
  5. mcpgateway/services/gateway_service.py
    - Fixed authentication encoding issue (early in session)
    - Added encode_auth import
  6. mcpgateway/utils/error_formatter.py - Fixed IndexError with empty location tuples

Created Files (3):

  1. tests/unit/mcpgateway/test_multi_auth_headers.py (NEW)
    - Comprehensive test suite with 14 test cases
    - Tests for validation, edge cases, backward compatibility
  2. docs/docs/using/multi-auth-headers.md (NEW)
    - Complete documentation for the feature
    - Usage examples, troubleshooting, best practices
  3. migration_add_multi_auth_headers.py (NEW - untracked)
    - Database migration script (though not needed as we reused existing field)

manavgup and others added 8 commits August 9, 2025 22:09
- Add support for linting specific files and directories via arguments
- Implement smart file type detection (Python, YAML, JSON, Markdown, TOML)
- Add convenience targets: lint-quick, lint-fix, lint-smart
- Add git integration: lint-changed, lint-staged, pre-commit hooks
- Fix TARGET variable parsing for multiple directories
- Remove duplicate lint-changed target definitions
- Add dummy targets to prevent 'No rule to make target' errors

Usage:
- make lint filename.py (single file)
- make lint dirname/ (directory)
- make lint-quick filename.py (fast linters only)
- make lint-changed (git changed files)

Resolves: 'mcpgateway tests is not a Python file or directory' error
Fixes: Duplicate target override warnings
Implements: All requirements from file-specific linting chore
- Fix gateway initialization failure with multi-header authentication by properly encoding header dictionaries before passing to _initialize_gateway()
- Fix error formatter IndexError when validation errors have empty location tuples
- Fix GatewayRead model to support multiple authentication headers instead of requiring exactly one

Resolves issue IBM#526 - multi-header authentication support
  - Add dynamic multi-header UI with add/remove functionality
  - Update backend validation to accept auth_headers array
  - Maintain backward compatibility with single header format
  - Add comprehensive tests and documentation
  - Handle edge cases (duplicates, validation, limits)

  Fixes IBM#526
Signed-off-by: Manav Gupta <manavg@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai force-pushed the fix/multi-header-auth-526 branch from 899e0b3 to c2d1b29 Compare August 9, 2025 21:38
Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch has been updated with:

  • ✅ Rebased onto main
  • ✅ Multi-header authentication feature implemented
  • ✅ All linting and formatting applied
  • ✅ Pylint score: 10.00/10
  • ✅ All tests passing: 1397 passed, 10 skipped
  • ✅ JavaScript formatting fixes applied
  • ✅ Test configuration issues resolved

@crivetimihai crivetimihai merged commit 3be2628 into IBM:main Aug 9, 2025
36 checks passed
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
* feat(makefile): add comprehensive file-specific linting support

- Add support for linting specific files and directories via arguments
- Implement smart file type detection (Python, YAML, JSON, Markdown, TOML)
- Add convenience targets: lint-quick, lint-fix, lint-smart
- Add git integration: lint-changed, lint-staged, pre-commit hooks
- Fix TARGET variable parsing for multiple directories
- Remove duplicate lint-changed target definitions
- Add dummy targets to prevent 'No rule to make target' errors

Usage:
- make lint filename.py (single file)
- make lint dirname/ (directory)
- make lint-quick filename.py (fast linters only)
- make lint-changed (git changed files)

Resolves: 'mcpgateway tests is not a Python file or directory' error
Fixes: Duplicate target override warnings
Implements: All requirements from file-specific linting chore

* fix: resolve multiple authentication headers and validation issues

- Fix gateway initialization failure with multi-header authentication by properly encoding header dictionaries before passing to _initialize_gateway()
- Fix error formatter IndexError when validation errors have empty location tuples
- Fix GatewayRead model to support multiple authentication headers instead of requiring exactly one

Resolves issue IBM#526 - multi-header authentication support

* feat: support multiple custom authentication headers for MCP gateways

  - Add dynamic multi-header UI with add/remove functionality
  - Update backend validation to accept auth_headers array
  - Maintain backward compatibility with single header format
  - Add comprehensive tests and documentation
  - Handle edge cases (duplicates, validation, limits)

  Fixes IBM#526

* fix: updated test assertion to match the updated validation when auth_headers is an empty list

* updated files with linter formatting

Signed-off-by: Manav Gupta <manavg@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Manav Gupta <manavg@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
* feat(makefile): add comprehensive file-specific linting support

- Add support for linting specific files and directories via arguments
- Implement smart file type detection (Python, YAML, JSON, Markdown, TOML)
- Add convenience targets: lint-quick, lint-fix, lint-smart
- Add git integration: lint-changed, lint-staged, pre-commit hooks
- Fix TARGET variable parsing for multiple directories
- Remove duplicate lint-changed target definitions
- Add dummy targets to prevent 'No rule to make target' errors

Usage:
- make lint filename.py (single file)
- make lint dirname/ (directory)
- make lint-quick filename.py (fast linters only)
- make lint-changed (git changed files)

Resolves: 'mcpgateway tests is not a Python file or directory' error
Fixes: Duplicate target override warnings
Implements: All requirements from file-specific linting chore

* fix: resolve multiple authentication headers and validation issues

- Fix gateway initialization failure with multi-header authentication by properly encoding header dictionaries before passing to _initialize_gateway()
- Fix error formatter IndexError when validation errors have empty location tuples
- Fix GatewayRead model to support multiple authentication headers instead of requiring exactly one

Resolves issue IBM#526 - multi-header authentication support

* feat: support multiple custom authentication headers for MCP gateways

  - Add dynamic multi-header UI with add/remove functionality
  - Update backend validation to accept auth_headers array
  - Maintain backward compatibility with single header format
  - Add comprehensive tests and documentation
  - Handle edge cases (duplicates, validation, limits)

  Fixes IBM#526

* fix: updated test assertion to match the updated validation when auth_headers is an empty list

* updated files with linter formatting

Signed-off-by: Manav Gupta <manavg@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Manav Gupta <manavg@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 16, 2025
* feat(makefile): add comprehensive file-specific linting support

- Add support for linting specific files and directories via arguments
- Implement smart file type detection (Python, YAML, JSON, Markdown, TOML)
- Add convenience targets: lint-quick, lint-fix, lint-smart
- Add git integration: lint-changed, lint-staged, pre-commit hooks
- Fix TARGET variable parsing for multiple directories
- Remove duplicate lint-changed target definitions
- Add dummy targets to prevent 'No rule to make target' errors

Usage:
- make lint filename.py (single file)
- make lint dirname/ (directory)
- make lint-quick filename.py (fast linters only)
- make lint-changed (git changed files)

Resolves: 'mcpgateway tests is not a Python file or directory' error
Fixes: Duplicate target override warnings
Implements: All requirements from file-specific linting chore

* fix: resolve multiple authentication headers and validation issues

- Fix gateway initialization failure with multi-header authentication by properly encoding header dictionaries before passing to _initialize_gateway()
- Fix error formatter IndexError when validation errors have empty location tuples
- Fix GatewayRead model to support multiple authentication headers instead of requiring exactly one

Resolves issue IBM#526 - multi-header authentication support

* feat: support multiple custom authentication headers for MCP gateways

  - Add dynamic multi-header UI with add/remove functionality
  - Update backend validation to accept auth_headers array
  - Maintain backward compatibility with single header format
  - Add comprehensive tests and documentation
  - Handle edge cases (duplicates, validation, limits)

  Fixes IBM#526

* fix: updated test assertion to match the updated validation when auth_headers is an empty list

* updated files with linter formatting

Signed-off-by: Manav Gupta <manavg@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Rebase, lint and revert Makefile changes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Manav Gupta <manavg@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.

[BUG][UI]: Unable to add multiple headers when adding gateway

2 participants