Sign media URLs to avoid becoming an open proxy

Signatures are valid for ~1 week.
This commit is contained in:
Kevin Wallace 2022-11-04 01:59:40 -07:00 committed by Thomas Sileo
parent 540b9d1470
commit a4cfd65009
4 changed files with 41 additions and 9 deletions

View file

@ -1,4 +1,5 @@
import hashlib
import hmac
import os
import secrets
from pathlib import Path
@ -250,3 +251,7 @@ def verify_csrf_token(
detail=f"The security token has expired, {please_try_again}",
)
return None
def hmac_sha256():
return hmac.new(CONFIG.secret.encode(), digestmod=hashlib.sha256)