aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/secure.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-14 20:03:04 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-16 20:29:26 +0100
commit49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed (patch)
tree68c59d67637a297d513e07ea96ba236a7f0cd43b /server/middlewares/secure.js
parent41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd (diff)
downloadPeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.tar.gz
PeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.tar.zst
PeerTube-49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed.zip
Pod URL -> pod host. HTTPS is required to make friends.
Reason: in a network with mix http/https pods, https pods won't be able to play videos from http pod (insecure requests).
Diffstat (limited to 'server/middlewares/secure.js')
-rw-r--r--server/middlewares/secure.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/server/middlewares/secure.js b/server/middlewares/secure.js
index 58f824d14..fd5bc51d6 100644
--- a/server/middlewares/secure.js
+++ b/server/middlewares/secure.js
@@ -12,27 +12,27 @@ const secureMiddleware = {
12} 12}
13 13
14function checkSignature (req, res, next) { 14function checkSignature (req, res, next) {
15 const url = req.body.signature.url 15 const host = req.body.signature.host
16 Pod.loadByUrl(url, function (err, pod) { 16 Pod.loadByHost(host, function (err, pod) {
17 if (err) { 17 if (err) {
18 logger.error('Cannot get signed url in decryptBody.', { error: err }) 18 logger.error('Cannot get signed host in decryptBody.', { error: err })
19 return res.sendStatus(500) 19 return res.sendStatus(500)
20 } 20 }
21 21
22 if (pod === null) { 22 if (pod === null) {
23 logger.error('Unknown pod %s.', url) 23 logger.error('Unknown pod %s.', host)
24 return res.sendStatus(403) 24 return res.sendStatus(403)
25 } 25 }
26 26
27 logger.debug('Decrypting body from %s.', url) 27 logger.debug('Decrypting body from %s.', host)
28 28
29 const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, url, req.body.signature.signature) 29 const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, host, req.body.signature.signature)
30 30
31 if (signatureOk === true) { 31 if (signatureOk === true) {
32 return next() 32 return next()
33 } 33 }
34 34
35 logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url) 35 logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.host)
36 return res.sendStatus(403) 36 return res.sendStatus(403)
37 }) 37 })
38} 38}