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 ++++------------------------ server/middlewares/validators/remote.js | 10 ---------- 2 files changed, 4 insertions(+), 34 deletions(-) (limited to 'server/middlewares') 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 diff --git a/server/middlewares/validators/remote.js b/server/middlewares/validators/remote.js index c6455e678..858d193cc 100644 --- a/server/middlewares/validators/remote.js +++ b/server/middlewares/validators/remote.js @@ -4,20 +4,10 @@ const checkErrors = require('./utils').checkErrors const logger = require('../../helpers/logger') const validatorsRemote = { - dataToDecrypt, remoteVideos, signature } -function dataToDecrypt (req, res, next) { - req.checkBody('key', 'Should have a key').notEmpty() - req.checkBody('data', 'Should have data').notEmpty() - - logger.debug('Checking dataToDecrypt parameters', { parameters: { keyLength: req.body.key.length, bodyLength: req.body.data.length } }) - - checkErrors(req, res, next) -} - function remoteVideos (req, res, next) { req.checkBody('data').isEachRemoteVideosValid() -- cgit v1.2.3