[Bug]: server rejects a lowercase or mixed-case bearer auth scheme with a correct key

オープン
#671 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

  • #672 @feiiiiii5 による — マージされずにクローズ

評価

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

調査の方向性

The header check is the startswith("Bearer ") comparison in agentlightning/server/app.py. Reproduce with the TestClient snippet in the issue, using bearer and BeArEr against /api/rollouts. Read the closed, unmerged PR #672 first to see why it was not merged. Done when the scheme is matched case-insensitively, extra spaces after it are accepted, and a wrong key or different scheme still returns 401.

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

説明

What happened?

The server rejects a valid API key when the Authorization header uses a lowercase or mixed-case auth scheme. agentlightning/server/app.py compares the header with startswith("Bearer "), so Authorization: bearer <valid key> and BeArEr <valid key> both return 401 Invalid or missing API key, while Bearer <valid key> succeeds.

RFC 7235 §2.1 makes the auth-scheme token case-insensitive and allows one or more spaces between scheme and credentials. Clients and gateways that normalize the scheme to lowercase therefore cannot authenticate, and the 401 does not point at the cause.

Steps to reproduce
from fastapi.testclient import TestClient
from agentlightning.server.app import create_app

app = create_app({"key": "secret", "default_proxy": {}})
client = TestClient(app)
client.get("/api/rollouts", params={"state_in": "queuing"}, headers={"Authorization": "bearer secret"})
# -> 401 Invalid or missing API key

With Authorization: Bearer secret the same request returns 200.

Expected behavior

A correct key is accepted for any valid auth-scheme casing and for extra spaces after the scheme. A wrong key or a different scheme still returns 401.

主要言語
Python
スター
18.9k
フォーク
1.7k
平均マージ
4日 11時間
マージ済み PR(30日)
9

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

microsoft/agent-lightning のほかの issue

microsoft/agent-lightning の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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