mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Add allowed_langs filter
This commit is contained in:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user