From cc0d18869a7485ba8b2bc80beeff323ff465c0ed Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 8 Aug 2023 15:33:35 -0400 Subject: [PATCH] test: fixed improper signed_string reconstruction in `.verify()` --- src/activitypub/index.js | 2 +- test/activitypub.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/activitypub/index.js b/src/activitypub/index.js index 95f1e98024..a986cb2335 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -136,7 +136,7 @@ ActivityPub.verify = async (req) => { // Re-construct signature string const signed_string = headers.split(' ').reduce((memo, cur) => { if (cur === '(request-target)') { - memo.push(`${cur}: ${String(req.method).toLowerCase()} ${req.path}`); + memo.push(`${cur}: ${String(req.method).toLowerCase()} ${req.baseUrl}${req.path}`); } else if (req.headers.hasOwnProperty(cur)) { memo.push(`${cur}: ${req.headers[cur]}`); } diff --git a/test/activitypub.js b/test/activitypub.js index d56a57395b..d59fe1cbc1 100644 --- a/test/activitypub.js +++ b/test/activitypub.js @@ -261,9 +261,11 @@ describe('ActivityPub integration', () => { describe('.verify()', () => { let uid; let username; + const baseUrl = nconf.get('relative_path'); const mockReqBase = { method: 'GET', // path: ... + baseUrl, headers: { // host: ... // date: ...