Tweak HTTPsig

main
Thomas Sileo 2022-07-14 19:43:02 +02:00
parent 61c3c3e214
commit 426669d870
2 changed files with 9 additions and 3 deletions

View File

@ -107,7 +107,11 @@ class NotAnObjectError(Exception):
self.resp = resp
async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
async def fetch(
url: str,
params: dict[str, Any] | None = None,
disable_httpsig: bool = False,
) -> RawObject:
async with httpx.AsyncClient() as client:
resp = await client.get(
url,
@ -117,7 +121,7 @@ async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
},
params=params,
follow_redirects=True,
auth=auth,
auth=None if disable_httpsig else auth,
)
# Special handling for deleted object

View File

@ -90,7 +90,9 @@ async def _get_public_key(db_session: AsyncSession, key_id: str) -> Key:
# Fetch it
from app import activitypub as ap
actor = await ap.fetch(key_id)
# Without signing the request as if it's the first contact, the 2 servers
# might race to fetch each other key
actor = await ap.fetch(key_id, disable_httpsig=True)
if actor["type"] == "Key":
# The Key is not embedded in the Person
k = Key(actor["owner"], actor["id"])