APIKeyAuth cookie mode overwrites existing Cookie headers

オープン 初心者向け
#9,706 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Kiko0301 がすでに取り組んでいます。

2026年11月24日 から。

  • #9711 @Kiko0301 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

lib/crewai/src/crewai/a2a/auth/client_schemes.py の APIKeyAuth.apply_auth から始めてください。ここでは cookie の分岐が Cookie ヘッダー全体を置き換えています。再現用のスニペットを使い捨てのスクリプトにコピーして、session と theme のペアが消えることを確認してください。そのうえで、分岐が既存のヘッダーを大文字と小文字を区別せずに検索し、代入ではなく ; name=key を追記するように変更します。既存のケースと新しいケースは lib/crewai/tests/a2a/test_client_schemes.py にあります。このファイルを実行して、値の保持、ヘッダーがない場合の作成、小文字の cookie の再利用を確認してください。報告者によると修正 PR が後から提出される予定なので、作業が重複しないようメンテナーに確認してください。

索引モデルが issue の本文から書いたものです。

説明

Description

In lib/crewai/src/crewai/a2a/auth/client_schemes.py, APIKeyAuth.apply_auth handles the cookie location by assigning the whole Cookie header:

if self.location == "header":
    headers[self.name] = self.api_key
elif self.location == "cookie":
    headers["Cookie"] = f"{self.name}={self.api_key}"

Any cookies already present on the request are discarded. A client that carries a session cookie (or any other cookie) and uses API key auth in cookie mode loses those cookies, so the server sees only the API key pair.

Reproduction

import asyncio
from crewai.a2a.auth.client_schemes import APIKeyAuth

auth = APIKeyAuth(api_key="secret", location="cookie", name="api_key")
headers = {"Cookie": "session=abc123; theme=dark"}

print(asyncio.run(auth.apply_auth(None, headers)))
# {'Cookie': 'api_key=secret'}

On current main (d1aa368749f932311a6c1916e63a756877cab55a) the pre-existing session=abc123; theme=dark pair is gone.

Expected behavior

The API key is added as an additional cookie pair (session=abc123; theme=dark; api_key=secret), preserving existing cookies and the header's original casing when it is already present.

Suggested fix

Look up an existing Cookie header case-insensitively, append ; <name>=<key> when one exists, and create the header only when absent. A fix PR will follow.

Tests

New tests in lib/crewai/tests/a2a/test_client_schemes.py cover preserving an existing Cookie header, creating it when absent, and reusing a lowercase cookie header name. Two of the three fail on unmodified main.

Prepared with an AI coding agent. Please apply the llm-generated label; this account cannot set repository labels.

主要言語
Python
スター
61.2k
フォーク
9.2k
平均マージ
1日 13時間
マージ済み PR(30日)
221

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。