mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
fix: #13014, possible fix for peertube incompatibility: strip hash value from key IDs during check
This commit is contained in:
@@ -107,13 +107,13 @@ middleware.assertPayload = async function (req, res, next) {
|
|||||||
|
|
||||||
// Cross-check key ownership against received actor
|
// Cross-check key ownership against received actor
|
||||||
await activitypub.actors.assert(actor);
|
await activitypub.actors.assert(actor);
|
||||||
const compare = await db.getObjectField(`userRemote:${actor}:keys`, 'id');
|
const compare = (await db.getObjectField(`userRemote:${actor}:keys`, 'id')).replace(/#[\w-]+$/, '');
|
||||||
const { signature } = req.headers;
|
const { signature } = req.headers;
|
||||||
const keyId = new Map(signature.split(',').filter(Boolean).map((v) => {
|
const keyId = new Map(signature.split(',').filter(Boolean).map((v) => {
|
||||||
const index = v.indexOf('=');
|
const index = v.indexOf('=');
|
||||||
return [v.substring(0, index), v.slice(index + 1)];
|
return [v.substring(0, index), v.slice(index + 1)];
|
||||||
})).get('keyId');
|
})).get('keyId').slice(1, -1).replace(/#[\w-]+$/, '');
|
||||||
if (`"${compare}"` !== keyId) {
|
if (compare !== keyId) {
|
||||||
activitypub.helpers.log('[middleware/activitypub] Key ownership cross-check failed.');
|
activitypub.helpers.log('[middleware/activitypub] Key ownership cross-check failed.');
|
||||||
return res.sendStatus(403);
|
return res.sendStatus(403);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user