13 lines
424 B
Python
13 lines
424 B
Python
import hmac
|
|
|
|
from fastapi import HTTPException, Request, status
|
|
|
|
|
|
def password_matches(submitted: str, configured: str) -> bool:
|
|
return hmac.compare_digest(submitted.encode("utf-8"), configured.encode("utf-8"))
|
|
|
|
|
|
def require_admin(request: Request) -> None:
|
|
if request.session.get("admin_authenticated") is not True:
|
|
raise HTTPException(status_code=status.HTTP_303_SEE_OTHER, headers={"Location": "/login"})
|