mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Tweak HTTPsig
This commit is contained in:
parent
61c3c3e214
commit
426669d870
2 changed files with 9 additions and 3 deletions
|
@ -107,7 +107,11 @@ class NotAnObjectError(Exception):
|
||||||
self.resp = resp
|
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:
|
async with httpx.AsyncClient() as client:
|
||||||
resp = await client.get(
|
resp = await client.get(
|
||||||
url,
|
url,
|
||||||
|
@ -117,7 +121,7 @@ async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
|
||||||
},
|
},
|
||||||
params=params,
|
params=params,
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
auth=auth,
|
auth=None if disable_httpsig else auth,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Special handling for deleted object
|
# Special handling for deleted object
|
||||||
|
|
|
@ -90,7 +90,9 @@ async def _get_public_key(db_session: AsyncSession, key_id: str) -> Key:
|
||||||
# Fetch it
|
# Fetch it
|
||||||
from app import activitypub as ap
|
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":
|
if actor["type"] == "Key":
|
||||||
# The Key is not embedded in the Person
|
# The Key is not embedded in the Person
|
||||||
k = Key(actor["owner"], actor["id"])
|
k = Key(actor["owner"], actor["id"])
|
||||||
|
|
Loading…
Reference in a new issue