fix(api): oauth offered as auth_type in Add Tool form but silently ignored by POST /tools and POST /admin/tools
Closes #5164
Summary
OAuth 2.0 appeared as a selectable authentication type in the Add Tool form, but submitting it was silently accepted with no effect — the tool was created with no authentication configured. This happens because ToolCreate and the Tool DB model have no oauth_config field; Pydantic silently drops unknown fields. OAuth on tools is inherited from the gateway the tool is registered under — the tool service reads gateway.oauth_config at invocation time. Direct OAuth configuration on a tool was never wired up, and _build_auth_obj_from_form in admin.py had no branch for oauth, so it returned None silently.
Changes
mcpgateway/templates/admin.html
Removed <option value="oauth">OAuth 2.0</option> from the Add Tool form (#add-tool-form). The option remains on gateway and A2A agent forms where OAuth is fully wired up.
mcpgateway/schemas.py
Added a field_validator on AuthenticationValues.auth_type that raises a ValueError (Pydantic 422) when auth_type is "oauth" (case-insensitive). This blocks POST /tools and POST /admin/tools API calls that submit auth_type=oauth.
mcpgateway/admin.py
Added an early HTTPException(422) in _build_auth_obj_from_form for auth_type == "oauth", covering the form-submission path.
Tests
test_admin.py: new test asserts_build_auth_obj_from_formraises 422 whenauth_type=oauthtest_schemas.py: three new tests coveringAuthenticationValuesrejection ofoauth(exact, case-insensitive, and valid-type acceptance)test_tools_extended.py(Playwright): updatedtest_auth_type_optionsto assertoauthis not attached to the add-tool form and to serve as a regression guard
Should we drop the option or add support to it? 🤔
Should we drop the option or add support to it? 🤔
I'm dropping it from the admin UI now. If we support it on the API, we can bring it up.
Should we drop the option or add support to it? 🤔
I'm dropping it from the admin UI now. If we support it on the API, we can bring it up.
Perfect. The code looks good, aproving! 🙇