From 75ba887d10eacb9cd1392e62f68617c7643c9add Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Jan 2020 15:17:42 +0100 Subject: Don't log error on actor delete signature error --- server/middlewares/activitypub.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/middlewares/activitypub.ts') diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index c906e785c..f3feae41e 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts @@ -1,10 +1,11 @@ import { NextFunction, Request, Response } from 'express' -import { ActivityPubSignature } from '../../shared' +import { ActivityDelete, ActivityPubSignature } from '../../shared' import { logger } from '../helpers/logger' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' +import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' async function checkSignature (req: Request, res: Response, next: NextFunction) { try { @@ -23,7 +24,13 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) return next() } catch (err) { - logger.warn('Error in ActivityPub signature checker.', err) + const activity: ActivityDelete = req.body + if (isActorDeleteActivityValid(activity) && activity.object === activity.actor) { + logger.debug('Handling signature error on actor delete activity', { err }) + return res.sendStatus(204) + } + + logger.warn('Error in ActivityPub signature checker.', { err }) return res.sendStatus(403) } } -- cgit v1.2.3