mirror of
https://github.com/bellingcat/whisperbox-transcribe.git
synced 2026-06-07 19:18:35 +03:00
17 lines
517 B
Python
17 lines
517 B
Python
from hmac import compare_digest
|
|
|
|
from fastapi import Depends, HTTPException
|
|
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
|
|
|
from app.shared.settings import settings
|
|
|
|
|
|
def authenticate_api_key(
|
|
credentials: HTTPAuthorizationCredentials = Depends(HTTPBearer(auto_error=False)),
|
|
) -> None:
|
|
# use compare_digest to counter timing attacks.
|
|
if not credentials or not compare_digest(
|
|
settings.API_SECRET, credentials.credentials
|
|
):
|
|
raise HTTPException(status_code=401)
|