Skip to content

Commit

Permalink
Fixed header type
Browse files Browse the repository at this point in the history
  • Loading branch information
danyi1212 committed Dec 22, 2024
1 parent f53a8dc commit dca5289
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions horizon/authentication.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Annotated

from fastapi import Header, HTTPException, status

from horizon.config import MOCK_API_KEY, sidecar_config
from horizon.startup.api_keys import get_env_api_key


def enforce_pdp_token(authorization: Header):
def enforce_pdp_token(authorization: Annotated[str | None, Header()]):
if authorization is None:
raise HTTPException(status.HTTP_401_UNAUTHORIZED, detail="Missing Authorization header")
schema, token = authorization.split(" ")
Expand All @@ -13,7 +15,7 @@ def enforce_pdp_token(authorization: Header):
raise HTTPException(status.HTTP_401_UNAUTHORIZED, detail="Invalid PDP token")


def enforce_pdp_control_key(authorization: Header):
def enforce_pdp_control_key(authorization: Annotated[str | None, Header()]):
if sidecar_config.CONTAINER_CONTROL_KEY == MOCK_API_KEY:
raise HTTPException(
status.HTTP_503_SERVICE_UNAVAILABLE,
Expand Down

0 comments on commit dca5289

Please sign in to comment.