This commit is contained in:
parent
fee55145d9
commit
b7533b566b
1 changed files with 8 additions and 11 deletions
|
@ -13,8 +13,7 @@ from sqlalchemy import select
|
||||||
|
|
||||||
|
|
||||||
async def inbox_prechecker(
|
async def inbox_prechecker(
|
||||||
request: fastapi.Request,
|
request: fastapi.Request, db_session: AsyncSession = fastapi.Depends(get_db_session)
|
||||||
db_session: AsyncSession = fastapi.Depends(get_db_session)
|
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Check http request
|
Check http request
|
||||||
|
@ -47,8 +46,7 @@ async def inbox_prechecker(
|
||||||
)
|
)
|
||||||
).one_or_none()
|
).one_or_none()
|
||||||
):
|
):
|
||||||
logger.info(f"Dropping unnecessary delete activity " +
|
logger.info(f"Dropping unnecessary delete activity " + payload["actor"])
|
||||||
payload["actor"])
|
|
||||||
raise fastapi.HTTPException(status_code=202)
|
raise fastapi.HTTPException(status_code=202)
|
||||||
except fastapi.HTTPException as http_exc:
|
except fastapi.HTTPException as http_exc:
|
||||||
raise http_exc
|
raise http_exc
|
||||||
|
@ -56,10 +54,7 @@ async def inbox_prechecker(
|
||||||
logger.exception("Failed to precheck delete activity")
|
logger.exception("Failed to precheck delete activity")
|
||||||
|
|
||||||
actor_id = payload["actor"]
|
actor_id = payload["actor"]
|
||||||
send_actor_id = parsec_signature["keyid"].split('#')[0]
|
send_actor_id = parsec_signature["keyid"].split("#")[0]
|
||||||
|
|
||||||
if actor_id != send_actor_id:
|
|
||||||
return await ldsig.verify_signature(db_session, payload)
|
|
||||||
|
|
||||||
_actor = await fetch_actor(db_session, actor_id)
|
_actor = await fetch_actor(db_session, actor_id)
|
||||||
|
|
||||||
|
@ -71,6 +66,9 @@ async def inbox_prechecker(
|
||||||
logger.warning("actor gone? ")
|
logger.warning("actor gone? ")
|
||||||
raise KeyError
|
raise KeyError
|
||||||
|
|
||||||
|
if actor_id != send_actor_id:
|
||||||
|
return await ldsig.verify_signature(db_session, payload)
|
||||||
|
|
||||||
body = await request.body()
|
body = await request.body()
|
||||||
signture_string = HttpSignature.build_signature_string(
|
signture_string = HttpSignature.build_signature_string(
|
||||||
request.method,
|
request.method,
|
||||||
|
@ -80,9 +78,8 @@ async def inbox_prechecker(
|
||||||
request.headers,
|
request.headers,
|
||||||
)
|
)
|
||||||
is_verify = HttpSignature.verify_signature(
|
is_verify = HttpSignature.verify_signature(
|
||||||
signture_string,
|
signture_string, parsec_signature["signature"], pubkey
|
||||||
parsec_signature["signature"],
|
)
|
||||||
pubkey)
|
|
||||||
|
|
||||||
logger.info(signture_string)
|
logger.info(signture_string)
|
||||||
logger.info(f"verify? {is_verify}")
|
logger.info(f"verify? {is_verify}")
|
||||||
|
|
Loading…
Reference in a new issue