fix: Disable CA Cert validation on authless MCPs#5075
Open
gcgoncalves wants to merge 1 commit into
Open
Conversation
0ab4563 to
0e70bbf
Compare
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
0e70bbf to
2fb22f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Bug-fix PR
📌 Summary
Closes #5070
🔁 Reproduction Steps
UI Reproduction Steps
API Reproduction Steps
Generate a valid JWT token for authentication:
export TOKEN=$(python -m mcpgateway.utils.create_jwt_token --username admin@example.com --exp 10080 --secret your-secret-key)Attempt to register an authless MCP server via POST /gateways:
Observe the validation error response:
{"detail":[{"type":"value_error","loc":["body","auth_value"],"msg":"Value error, Invalid 'auth_type'. Must be one of: basic, bearer, oauth, authheaders, or query_param.","input":null,"ctx":{"error":{}}}]}%Confirm the same error occurs with explicit null:
{"detail":[{"type":"value_error","loc":["body","auth_value"],"msg":"Value error, Invalid 'auth_type'. Must be one of: basic, bearer, oauth, authheaders, or query_param.","input":null,"ctx":{"error":{}}}]}%{"detail":[{"type":"string_pattern_mismatch","loc":["body","auth_query_param_key"],"msg":"String should match pattern '^[a-zA-Z_][a-zA-Z0-9_\\-]*$'","input":"","ctx":{"pattern":"^[a-zA-Z_][a-zA-Z0-9_\\-]*$"}},{"type":"value_error","loc":["body","auth_value"],"msg":"Value error, Invalid 'auth_type'. Must be one of: basic, bearer, oauth, authheaders, or query_param.","input":null,"ctx":{"error":{}}}]}%🐞 Root Cause
There is a mismatch between the UI form and backend validation: the admin UI's
auth_typedropdown sent an empty stringvalue=""for the"None"option, but the Pydantic schemas expected either a valid auth type string or PythonNone. The schemas lacked a validator to normalize the string"none"to Python None, causing validation failures when users selected "No authentication" in the UI.💡 Fix Description
This PR solves the issue by adding a Pydantic @field_validator to both
GatewayCreateandGatewayUpdateschemas that normalizes empty strings and the literal string"none"(case-insensitive) to PythonNone, ensuring the backend correctly interprets the UI's"No authentication"selection. The fix includes comprehensive test coverage for all auth_type variations (valid types, None, empty string, "none" string) across both create and update operations.🧪 Verification
make lintmake testmake coverage📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)