mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-14 18:40:11 +01:00
f4088d9348
* WIP integrity check between processes * Implement integrity checking on document processor payloads
21 lines
685 B
JavaScript
21 lines
685 B
JavaScript
const { CommunicationKey } = require("../utils/comKey");
|
|
|
|
function verifyPayloadIntegrity(request, response, next) {
|
|
const comKey = new CommunicationKey();
|
|
if (process.env.NODE_ENV === "development") {
|
|
comKey.log('verifyPayloadIntegrity is skipped in development.')
|
|
next();
|
|
return;
|
|
}
|
|
|
|
const signature = request.header("X-Integrity");
|
|
if (!signature) return response.status(400).json({ msg: 'Failed integrity signature check.' })
|
|
|
|
const validSignedPayload = comKey.verify(signature, request.body);
|
|
if (!validSignedPayload) return response.status(400).json({ msg: 'Failed integrity signature check.' })
|
|
next();
|
|
}
|
|
|
|
module.exports = {
|
|
verifyPayloadIntegrity
|
|
} |