mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(federation): ♻️ Allow ActivityPub bridge requests to omit all signature headers, including x-signed-by
This commit is contained in:
parent
80b5184d6a
commit
b55237cdc8
2 changed files with 39 additions and 6 deletions
|
|
@ -25,7 +25,11 @@ export const schemas = {
|
|||
header: z.object({
|
||||
"x-signature": z.string().optional(),
|
||||
"x-nonce": z.string().optional(),
|
||||
"x-signed-by": z.string().url().or(z.string().startsWith("instance ")),
|
||||
"x-signed-by": z
|
||||
.string()
|
||||
.url()
|
||||
.or(z.string().startsWith("instance "))
|
||||
.optional(),
|
||||
authorization: z.string().optional(),
|
||||
}),
|
||||
body: z.any(),
|
||||
|
|
@ -111,6 +115,32 @@ export default apiRoute((app) =>
|
|||
const logger = getLogger(["federation", "inbox"]);
|
||||
const body: Entity = await context.req.valid("json");
|
||||
|
||||
if (authorization) {
|
||||
const processor = new InboxProcessor(
|
||||
context,
|
||||
body,
|
||||
null,
|
||||
{
|
||||
signature,
|
||||
nonce,
|
||||
authorization,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
return await processor.process();
|
||||
}
|
||||
|
||||
// If not potentially from bridge, check for required headers
|
||||
if (!(signature && nonce && signedBy)) {
|
||||
return context.json(
|
||||
{
|
||||
error: "Missing required headers: x-signature, x-nonce, or x-signed-by",
|
||||
},
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
const sender = await User.resolve(signedBy);
|
||||
|
||||
if (!(sender || signedBy.startsWith("instance "))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue