Skip to content

fix(client): apply all schemes in multi-scheme security requirement (AND semantics)#1140

Open
arunmm8335 wants to merge 1 commit into
a2aproject:mainfrom
arunmm8335:fix/issue-1138
Open

fix(client): apply all schemes in multi-scheme security requirement (AND semantics)#1140
arunmm8335 wants to merge 1 commit into
a2aproject:mainfrom
arunmm8335:fix/issue-1138

Conversation

@arunmm8335

Copy link
Copy Markdown
Contributor

Fixes #1138

…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
@arunmm8335
arunmm8335 requested a review from a team as a code owner July 20, 2026 09:26

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AuthInterceptor applies only the first scheme of a multi-scheme security requirement (AND semantics broken)

1 participant