first commit
This commit is contained in:
commit
b47f825d54
83 changed files with 10016 additions and 0 deletions
14
backend/app/auth.py
Normal file
14
backend/app/auth.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from fastapi import HTTPException, Request
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
|
||||
def require_admin(request: Request) -> None:
|
||||
token = request.query_params.get("token")
|
||||
if token is None:
|
||||
auth_header = request.headers.get("authorization", "")
|
||||
if auth_header.startswith("Bearer "):
|
||||
token = auth_header.removeprefix("Bearer ")
|
||||
|
||||
if token is None or token != get_settings().admin_token:
|
||||
raise HTTPException(status_code=401, detail="Invalid or missing token")
|
||||
Loading…
Add table
Add a link
Reference in a new issue