aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-17 15:20:42 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 (patch)
treef91fcfa0fa1a2e45aae1c5333ef2f7ec60e56ef0 /server/middlewares
parent975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (diff)
downloadPeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.gz
PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.zst
PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.zip
Optimize signature verification
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/activitypub.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 0ea522e5c..8e8a3961b 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -1,9 +1,10 @@
1import { NextFunction, Request, Response, RequestHandler } from 'express' 1import { eachSeries } from 'async'
2import { NextFunction, Request, RequestHandler, Response } from 'express'
2import { ActivityPubSignature } from '../../shared' 3import { ActivityPubSignature } from '../../shared'
3import { isSignatureVerified, logger } from '../helpers' 4import { isSignatureVerified, logger } from '../helpers'
4import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub' 5import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub'
5import { database as db, ACTIVITY_PUB_ACCEPT_HEADER } from '../initializers' 6import { database as db } from '../initializers'
6import { each, eachSeries, waterfall } from 'async' 7import { ACTIVITY_PUB } from '../initializers/constants'
7 8
8async function checkSignature (req: Request, res: Response, next: NextFunction) { 9async function checkSignature (req: Request, res: Response, next: NextFunction) {
9 const signatureObject: ActivityPubSignature = req.body.signature 10 const signatureObject: ActivityPubSignature = req.body.signature
@@ -37,7 +38,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
37 38
38function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { 39function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
39 return (req: Request, res: Response, next: NextFunction) => { 40 return (req: Request, res: Response, next: NextFunction) => {
40 if (req.header('Accept') !== ACTIVITY_PUB_ACCEPT_HEADER) { 41 if (req.header('Accept') !== ACTIVITY_PUB.ACCEPT_HEADER) {
41 return next() 42 return next()
42 } 43 }
43 44