From 615df05bf14c65172866c510facdc7ea7a1feb8f Mon Sep 17 00:00:00 2001 From: Manish <88748362+mnshai@users.noreply.github.com> Date: Mon, 3 Mar 2025 22:59:43 +0530 Subject: [PATCH] refactor: update authentication scheme handling in HTTPBase --- fastapi/security/http.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fastapi/security/http.py b/fastapi/security/http.py index d9de1f0d7..e26d85932 100644 --- a/fastapi/security/http.py +++ b/fastapi/security/http.py @@ -75,10 +75,11 @@ class HTTPBase(SecurityBase): description: Optional[str] = None, auto_error: bool = True, ): - self.model = HTTPBaseModel(scheme=scheme, description=description) + self.model: HTTPBaseModel = HTTPBaseModel( + scheme=scheme, description=description + ) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error - self.scheme = scheme async def __call__( self, request: Request @@ -90,7 +91,7 @@ class HTTPBase(SecurityBase): raise HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail="Not authenticated", - headers={"WWW-Authenticate": self.scheme}, + headers={"WWW-Authenticate": self.model.scheme}, ) else: