[feat] inbox checker add logger
This commit is contained in:
parent
6cd142a0a0
commit
157073a4a7
1 changed files with 6 additions and 4 deletions
|
@ -4,17 +4,19 @@ import json
|
||||||
from flask import Request, abort
|
from flask import Request, abort
|
||||||
from demo.httpsig import HttpSignature, SignedData
|
from demo.httpsig import HttpSignature, SignedData
|
||||||
from demo.actor import fetch_actor
|
from demo.actor import fetch_actor
|
||||||
|
from app import logger
|
||||||
|
|
||||||
|
|
||||||
def inbox_prechecker(
|
def inbox_prechecker(
|
||||||
request: Request,
|
request: Request,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Inbox request prechecker"""
|
"""Inbox request prechecker"""
|
||||||
payload = request.headers
|
headers = request.headers
|
||||||
ap_body = request.data
|
payload = request.data
|
||||||
|
logger.debug(f"new request {payload=}\n{headers=}")
|
||||||
try:
|
try:
|
||||||
parsed_signature = HttpSignature.parse_signature(
|
parsed_signature = HttpSignature.parse_signature(
|
||||||
payload["signature"]
|
headers["signature"]
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
abort(401, "Missing signature key!")
|
abort(401, "Missing signature key!")
|
||||||
|
@ -34,7 +36,7 @@ def inbox_prechecker(
|
||||||
method = request.method,
|
method = request.method,
|
||||||
path = request.path,
|
path = request.path,
|
||||||
signed_list = parsed_signature["headers"],
|
signed_list = parsed_signature["headers"],
|
||||||
body_digest = HttpSignature.calculation_digest(ap_body),
|
body_digest = HttpSignature.calculation_digest(payload),
|
||||||
headers = request.headers,
|
headers = request.headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue