From 38d78e5b82a30d1318e3cc2532b7ea22b8e163fa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 27 Nov 2016 18:25:35 +0100 Subject: Server: remove encryption when seending requests to other pods We don't need it anymore since HTTPS is mandatory now --- server/middlewares/secure.js | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'server/middlewares/secure.js') diff --git a/server/middlewares/secure.js b/server/middlewares/secure.js index fd5bc51d6..ee836beed 100644 --- a/server/middlewares/secure.js +++ b/server/middlewares/secure.js @@ -7,15 +7,14 @@ const peertubeCrypto = require('../helpers/peertube-crypto') const Pod = mongoose.model('Pod') const secureMiddleware = { - checkSignature, - decryptBody + checkSignature } function checkSignature (req, res, next) { const host = req.body.signature.host Pod.loadByHost(host, function (err, pod) { if (err) { - logger.error('Cannot get signed host in decryptBody.', { error: err }) + logger.error('Cannot get signed host in body.', { error: err }) return res.sendStatus(500) } @@ -24,7 +23,7 @@ function checkSignature (req, res, next) { return res.sendStatus(403) } - logger.debug('Decrypting body from %s.', host) + logger.debug('Checking signature from %s.', host) const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, host, req.body.signature.signature) @@ -32,30 +31,11 @@ function checkSignature (req, res, next) { return next() } - logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.host) + logger.error('Signature is not okay in body for %s.', req.body.signature.host) return res.sendStatus(403) }) } -function decryptBody (req, res, next) { - peertubeCrypto.decrypt(req.body.key, req.body.data, function (err, decrypted) { - if (err) { - logger.error('Cannot decrypt data.', { error: err }) - return res.sendStatus(500) - } - - try { - req.body.data = JSON.parse(decrypted) - delete req.body.key - } catch (err) { - logger.error('Error in JSON.parse', { error: err }) - return res.sendStatus(500) - } - - next() - }) -} - // --------------------------------------------------------------------------- module.exports = secureMiddleware -- cgit v1.2.3