Browse Source

relax HTTPBearer call requirement to support websockets

pull/13481/head
Florian Sattler 4 weeks ago
parent
commit
2931041104
  1. 4
      fastapi/security/http.py

4
fastapi/security/http.py

@ -8,7 +8,7 @@ from fastapi.openapi.models import HTTPBearer as HTTPBearerModel
from fastapi.security.base import SecurityBase
from fastapi.security.utils import get_authorization_scheme_param
from pydantic import BaseModel
from starlette.requests import Request
from starlette.requests import Request, HTTPConnection
from starlette.status import HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN
from typing_extensions import Annotated, Doc
@ -299,7 +299,7 @@ class HTTPBearer(HTTPBase):
self.auto_error = auto_error
async def __call__(
self, request: Request
self, request: HTTPConnection
) -> Optional[HTTPAuthorizationCredentials]:
authorization = request.headers.get("Authorization")
scheme, credentials = get_authorization_scheme_param(authorization)

Loading…
Cancel
Save