mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
21 lines
559 B
Python
21 lines
559 B
Python
from typing import Optional
|
|
|
|
from fastapi import Security, HTTPException, Query, status
|
|
|
|
from core.auth import default_security
|
|
from core.config import env_config
|
|
|
|
|
|
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"]
|