X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Factivitypub.ts;h=b1e5b52369c115dadc556264262c1db4260c2f47;hb=0283eaac2a8e73006c66df3cf5bb9012e37450e5;hp=5fa10cbfd0dae467e3e5937d222702657e5ba299;hpb=e65c0c5b1fab9c3d93f51721b2458cf5cf471f20;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 5fa10cbfd..b1e5b5236 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts @@ -2,9 +2,8 @@ import { NextFunction, Request, Response } from 'express' import { 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' +import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' -import { ActorModel } from '../models/activitypub/actor' import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' async function checkSignature (req: Request, res: Response, next: NextFunction) { @@ -12,7 +11,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) const httpSignatureChecked = await checkHttpSignature(req, res) if (httpSignatureChecked !== true) return - const actor: ActorModel = res.locals.signature.actor + const actor = res.locals.signature.actor // Forwarded activity const bodyActor = req.body.actor @@ -75,6 +74,8 @@ async function checkHttpSignature (req: Request, res: Response) { const verified = isHTTPSignatureVerified(parsed, actor) if (verified !== true) { + logger.warn('Signature from %s is invalid', actorUrl, { parsed }) + res.sendStatus(403) return false }