feat(a2a): Add API key authentication provider - #19548
Conversation
|
Hi @adamfweidman, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello @adamfweidman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the authentication capabilities for A2A agents by introducing a dedicated API key authentication provider. It allows for flexible API key management, including dynamic resolution from environment variables or shell commands, and incorporates intelligent retry mechanisms for command-based keys. The changes also refine authentication configuration schemas, improving validation and clarity for developers. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Size Change: +121 B (0%) Total Size: 24.5 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request introduces the ApiKeyAuthProvider for A2A agents, enabling authentication via API keys in HTTP headers and supporting dynamic key resolution from environment variables and shell commands. However, a critical command injection vulnerability exists due to the allowance of API keys to be resolved from shell commands within ApiKeyAuthProvider, specifically in the initialize and shouldRetryWithHeaders methods. This poses a significant Remote Code Execution (RCE) risk. It is strongly recommended to disable this feature entirely. On a positive note, the PR also improves validation in agentLoader.ts and includes comprehensive unit tests.
Summary
Adds
ApiKeyAuthProviderfor authenticating with remote A2A agents using API keys. Keys are sent as HTTP headers with support for dynamic credential resolution via environment variables ($ENV_VAR) and shell commands (!command).Details
ApiKeyAuthProvidersends API key as a configurable header (default:X-API-Key)!command-based keys on 401/403 with retry limit; skips retry for literal/env-var keys since resending identical headers is pointlessapiKeycase inA2AAuthProviderFactoryApiKeyAuthConfigto header-only (query/cookie not yet supported)BaseA2AAuthProviderretry fields toprotectedso subclasses can implement custom retry logic.min(1)validation on HTTP auth string fields in Zod schemaRelated Issues
Related to #17597
How to Validate
npm run testPre-Merge Checklist