fix(client): apply all schemes in multi-scheme security requirement (AND semantics)#1140
fix(client): apply all schemes in multi-scheme security requirement (AND semantics)#1140arunmm8335 wants to merge 1 commit into
Conversation
…AND semantics) AuthInterceptor.before() previously returned after applying the first credential, even when a SecurityRequirement listed multiple schemes that must all be satisfied together (AND semantics per OpenAPI spec). This change introduces a two-pass approach per requirement: - Pass 1: collect credentials for every scheme; if any is unavailable or unsupported, mark the requirement as unsatisfiable and skip it. - Pass 2: apply all collected credentials at once, then return. The outer loop over security_requirements retains OR semantics: the first fully satisfiable requirement is used. A _resolve_header() static helper was extracted to map each scheme type to its (header_name, value) pair, improving readability and keeping the collection loop clean. Added 5 new test cases covering: - Multi-scheme AND (the exact issue reproduction) - Multi-requirement OR fallback - Partial requirement prevention - Mixed Bearer + API key in a single requirement - Unsupported scheme type (query API key) fallback Fixes a2aproject#1138
There was a problem hiding this comment.
Code Review
This pull request refactors the AuthInterceptor to correctly implement OpenAPI Security Requirement semantics, utilizing a two-pass approach to handle AND semantics within a single requirement and OR semantics across multiple requirements. It also extracts header resolution into a helper method and adds comprehensive unit tests to verify these behaviors. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/auth/interceptor.py | 85.42% | 98.51% | 🟢 +13.09% |
| Total | 92.95% | 93.04% | 🟢 +0.08% |
Generated by coverage-comment.yml
Fixes #1138