Add allowed_langs filter

This commit is contained in:
2022-01-02 20:15:55 +03:00
parent cbba30f2af
commit 017cc05a19
9 changed files with 170 additions and 53 deletions

View File

@@ -1,11 +1,20 @@
from fastapi import Security, HTTPException, status
from typing import Optional
from fastapi import Security, HTTPException, Query, status
from core.auth import default_security
from core.config import env_config
async def check_token(api_key: str = Security(default_security)):
def check_token(api_key: str = Security(default_security)):
if api_key != env_config.API_KEY:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN, detail="Wrong api key!"
)
def get_allowed_langs(allowed_langs: Optional[list[str]] = Query(None)) -> list[str]:
if allowed_langs is not None:
return allowed_langs
return ["ru", "be", "uk"]