From 4c8f121f5829d846eaa37019c59ae6b2e9fc1d92 Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Sun, 12 Apr 2026 17:25:35 +0000 Subject: [PATCH] Fix hallucination over FastAPI Basic auth --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index fbfb635..38890cb 100644 --- a/main.py +++ b/main.py @@ -19,17 +19,17 @@ app = FastAPI() file_mapping = {} indexers = [] -AUTH_SCHEME = HTTPBasic() +security = HTTPBasic() expected_password: str | None = None -async def get_current_username(credentials: HTTPBasicCredentials = Depends(AUTH_SCHEME)) -> str: +async def get_current_username(credentials: Annotated[HTTPBasicCredentials, Depends(security)]) -> str: """Verify Basic Authentication credentials""" if expected_password is not None and credentials.password != expected_password: raise HTTPException( status_code=401, detail="Incorrect password", - headers={"WWW-Authenticate": AUTH_SCHEME.getobfuscation_header()}, + headers={"WWW-Authenticate": "Basic"}, ) return credentials.username