diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 15:20:42 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 (patch) | |
tree | f91fcfa0fa1a2e45aae1c5333ef2f7ec60e56ef0 /server/middlewares | |
parent | 975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (diff) | |
download | PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.gz PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.zst PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.zip |
Optimize signature verification
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/activitypub.ts | 9 |
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 @@ | |||
1 | import { NextFunction, Request, Response, RequestHandler } from 'express' | 1 | import { eachSeries } from 'async' |
2 | import { NextFunction, Request, RequestHandler, Response } from 'express' | ||
2 | import { ActivityPubSignature } from '../../shared' | 3 | import { ActivityPubSignature } from '../../shared' |
3 | import { isSignatureVerified, logger } from '../helpers' | 4 | import { isSignatureVerified, logger } from '../helpers' |
4 | import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub' | 5 | import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub' |
5 | import { database as db, ACTIVITY_PUB_ACCEPT_HEADER } from '../initializers' | 6 | import { database as db } from '../initializers' |
6 | import { each, eachSeries, waterfall } from 'async' | 7 | import { ACTIVITY_PUB } from '../initializers/constants' |
7 | 8 | ||
8 | async function checkSignature (req: Request, res: Response, next: NextFunction) { | 9 | async 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 | ||
38 | function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { | 39 | function 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 | ||