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

Đang mở
#671 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@VISHNU0906 đang làm issue này rồi.

Từ ngày 6/11/2026.

  • #672 của @feiiiiii5 — đã đóng, không merge
  • #699 của @VISHNU0906 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
fastapi, python
Lĩnh vực
authentication, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
18.9k
Fork
1.7k
Merge trung bình
5 ngày 19 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/agent-lightning

Tất cả issue của microsoft/agent-lightning

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.