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: