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

Aperta
#671 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@VISHNU0906 ci sta già lavorando.

Dal 6/11/2026.

  • #672 di @feiiiiii5 — chiusa senza merge
  • #699 di @VISHNU0906 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
fastapi, python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
18.9k
Fork
1.7k
Merge medio
5g 19h
PR unite (30g)
14

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/agent-lightning

Tutte le issue di microsoft/agent-lightning

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.