diff options
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r-- | server/helpers/peertube-crypto.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index b8f7c782a..1a7ee24a7 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts | |||
@@ -51,11 +51,18 @@ function isHTTPSignatureVerified (httpSignatureParsed: any, actor: MActor): bool | |||
51 | } | 51 | } |
52 | 52 | ||
53 | function parseHTTPSignature (req: Request, clockSkew?: number) { | 53 | function parseHTTPSignature (req: Request, clockSkew?: number) { |
54 | const headers = req.method === 'POST' | 54 | const requiredHeaders = req.method === 'POST' |
55 | ? HTTP_SIGNATURE.REQUIRED_HEADERS.POST | 55 | ? [ '(request-target)', 'host', 'digest' ] |
56 | : HTTP_SIGNATURE.REQUIRED_HEADERS.ALL | 56 | : [ '(request-target)', 'host' ] |
57 | 57 | ||
58 | return httpSignature.parse(req, { clockSkew, headers }) | 58 | const parsed = httpSignature.parse(req, { clockSkew, headers: requiredHeaders }) |
59 | |||
60 | const parsedHeaders = parsed.params.headers | ||
61 | if (!parsedHeaders.includes('date') && !parsedHeaders.includes('(created)')) { | ||
62 | throw new Error(`date or (created) must be included in signature`) | ||
63 | } | ||
64 | |||
65 | return parsed | ||
59 | } | 66 | } |
60 | 67 | ||
61 | // JSONLD | 68 | // JSONLD |