-
Notifications
You must be signed in to change notification settings - Fork 38
feat: Add auth_tools support and fix test infrastructure #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…eration - Add auth_tools field to HttpCallTemplate for tool-specific authentication - Implement compatibility checking between OpenAPI security schemes and auth_tools - Apply real credentials when compatible, use placeholders when incompatible - Preserve existing behavior for public endpoints (no auth required) - Add comprehensive test coverage for all authentication scenarios - Update documentation with auth_tools examples and usage - Maintain full backward compatibility
- Update HttpCallTemplate, HttpCommunicationProtocol, and OpenApiConverter - Add auth_tools examples to README.md - Update existing tests for new auth_tools parameter - Add integration test for auth_tools field functionality
- Fix aiohttp_client fixture usage by properly injecting app dependency - Ensure all test fixtures receive required parameters correctly - All 153 tests now pass without fixture conflicts
- Add auth_tools field to TextCallTemplate for OpenAPI-generated tools - Pass auth_tools to OpenApiConverter when processing local OpenAPI specs - Update documentation to reflect new authentication capabilities - Add test coverage for auth_tools functionality - Maintains backward compatibility (auth_tools is optional) This allows text plugin to apply authentication to tools generated from local OpenAPI specifications, enabling secure API calls while keeping file access authentication-free.
325a20b
to
1589bdf
Compare
addresses #67 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 11 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="plugins/communication_protocols/text/src/utcp_text/text_call_template.py">
<violation number="1" location="plugins/communication_protocols/text/src/utcp_text/text_call_template.py:27">
auth_tools lacks serializer/validator; dict configs will lose critical fields when validated as Auth. Add field_serializer/field_validator using AuthSerializer like the existing auth field.</violation>
</file>
<file name="README.md">
<violation number="1" location="README.md:379">
Misleading comment: 'auth' is described as OpenAPI spec URL auth in a tool call example; should describe HTTP request auth.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
plugins/communication_protocols/text/src/utcp_text/text_call_template.py
Show resolved
Hide resolved
README.md
Outdated
"http_method": "POST", // Required, default: "GET" | ||
"content_type": "application/json", // Optional, default: "application/json" | ||
"auth": { // Optional, example using ApiKeyAuth for a Bearer token. The client must prepend "Bearer " to the token. | ||
"auth": { // Optional, authentication for accessing the OpenAPI spec URL (example using ApiKeyAuth for Bearer token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading comment: 'auth' is described as OpenAPI spec URL auth in a tool call example; should describe HTTP request auth.
Prompt for AI agents
Address the following comment on README.md at line 379:
<comment>Misleading comment: 'auth' is described as OpenAPI spec URL auth in a tool call example; should describe HTTP request auth.</comment>
<file context>
@@ -376,12 +376,18 @@ Configuration examples for each protocol. Remember to replace `provider_type` wi
"http_method": "POST", // Required, default: "GET"
"content_type": "application/json", // Optional, default: "application/json"
- "auth": { // Optional, example using ApiKeyAuth for a Bearer token. The client must prepend "Bearer " to the token.
+ "auth": { // Optional, authentication for accessing the OpenAPI spec URL (example using ApiKeyAuth for Bearer token)
"auth_type": "api_key",
"api_key": "Bearer $API_KEY", // Required
</file context>
"auth": { // Optional, authentication for accessing the OpenAPI spec URL (example using ApiKeyAuth for Bearer token) | |
"auth": { // Optional, authentication for the HTTP request (example using ApiKeyAuth for Bearer token) |
✅ Addressed in 7933fd4
- Add field_serializer and field_validator for auth_tools in TextCallTemplate - Add field_serializer and field_validator for both auth and auth_tools in HttpCallTemplate - Use AuthSerializer.validate_dict() for proper dict-to-Auth conversion - Add comprehensive test coverage for auth_tools serialization - Ensures dict configurations preserve all critical authentication fields - All 155 tests pass with proper field validation
Key Features Added
🔐 Auth_tools Support
• HTTP Plugin: Added auth_tools field to HttpCallTemplate for tool-specific authentication
• Text Plugin: Added auth_tools support for local OpenAPI specs
• Smart Authentication: Compatible auth schemes use real credentials, incompatible ones use placeholders
• Public Endpoints: Remain accessible without authentication requirements
🤖 Auto-Discovery of Authentication Requirements
• AuthToolsConfig: New wrapper class with auto_discover and verify_auth options
• Endpoint Testing: Automatically tests endpoints with unauthenticated requests
• Smart Classification:
• 200/2xx → Public endpoint (no auth needed)
• 401/403 → Requires authentication
• Other → Assumes public for safety
• Credential Verification: Optional validation that provided auth actually works
• Override Specs: Ignores potentially incorrect OpenAPI security definitions
🧪 Test Infrastructure Fixes
• Pytest Fixtures: Resolved aiohttp_client dependency issues in HTTP tests
• Test Coverage: All 163 tests now pass without conflicts
• Comprehensive Testing: Added auth_tools integration tests and auto-discovery test suite
Technical Implementation
Authentication Logic
• Analyzes OpenAPI security schemes vs provided auth_tools
• convert_async() method with auto-discovery support
• Applies authentication only to compatible/required endpoints
• Maintains backward compatibility (auth_tools is optional)
• Preserves existing behavior for public APIs
Auto-Discovery Process
Plugin Support
• HTTP Plugin: Full auth_tools support with auto-discovery for remote OpenAPI specs
• Text Plugin: Auth_tools support with auto-discovery for local OpenAPI files
• Consistent API: Same auth_tools interface across both plugins
Configuration Examples
Basic Auth_tools
Auto-Discovery Configuration
Documentation Updates
• Updated README.md with auth_tools and auto-discovery configuration examples
• Enhanced plugin-specific documentation
• Added usage examples for both HTTP and text plugins
• Complete auto-discovery guide and benefits
Backward Compatibility
✅ All existing functionality preserved
✅ Optional auth_tools field maintains compatibility
✅ AuthToolsConfig supports both dict and Auth object formats
✅ No breaking changes to existing APIs
Testing
• 163/163 tests passing
• New integration tests for auth_tools functionality
• Comprehensive auto-discovery test suite
• AuthToolsConfig serialization/validation tests
• Comprehensive coverage of authentication scenarios