Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aidial_sdk/deployment/from_request_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from urllib.parse import urljoin

import fastapi
from fastapi.security import HTTPBearer

from aidial_sdk.exceptions import InternalServerError, InvalidRequestError
from aidial_sdk.pydantic_v1 import Field, SecretStr, StrictStr, root_validator
Expand Down Expand Up @@ -34,6 +35,7 @@ class FromRequestDeploymentMixin(FromRequestMixin):

_DIAL_APPLICATION_PROPERTIES_HEADER = "X-DIAL-APPLICATION-PROPERTIES"
_DIAL_APPLICATION_ID_HEADER = "X-DIAL-APPLICATION-ID"
_bearer = HTTPBearer(auto_error=False)

headers: Mapping[str, str]
base_url: Optional[str] = None
Expand Down Expand Up @@ -139,7 +141,8 @@ async def from_request(
raise InvalidRequestError("Api-Key header is required")
del headers["Api-Key"]

jwt = headers.get("Authorization")
auth_credentials = await cls._bearer(request)
jwt = auth_credentials.credentials if auth_credentials else None
del headers["Authorization"]

application_properties = None
Expand Down
Loading