feat/add some precheck

This commit is contained in:
SouthFox 2023-03-19 11:48:10 +08:00
parent e480f77172
commit dcd862180e

View file

@ -20,12 +20,17 @@ async def httpsig_checker(
Check http signature
"""
payload = await request.json()
try:
logger.info(f"headers={request.headers}")
logger.info(f"{payload=}")
parsec_signature = HttpSignature.parse_signature(
request.headers.get("signature")
)
except KeyError:
logger.warning("Not signature headers")
raise KeyError
actor_url = payload["actor"]
async with httpx.AsyncClient() as client:
@ -43,6 +48,9 @@ async def httpsig_checker(
pubkey = _actor["publicKey"]["publicKeyPem"]
except json.JSONDecodeError:
raise ValueError
except KeyError:
logger.warning("actor gone? ")
raise KeyError
body = await request.body()
signture_string = HttpSignature.build_signature_string(