diff options
author | Chocobozzz <me@florianbigard.com> | 2022-12-02 14:47:21 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-12-02 15:25:20 +0100 |
commit | 71e3e879c0616882ee82a0e44f8c2e5ee9698a3e (patch) | |
tree | 14452d26d240eb6d44178b76fc2dabda4cfc9428 /server/middlewares/validators | |
parent | 04509c43254dc232c61681ac4bb98e09fd126115 (diff) | |
download | PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.gz PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.zst PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.zip |
Support reinjecting token in private m3u8 playlist
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/static.ts | 11 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/server/middlewares/validators/static.ts b/server/middlewares/validators/static.ts index 13fde6dd1..d3d307787 100644 --- a/server/middlewares/validators/static.ts +++ b/server/middlewares/validators/static.ts | |||
@@ -2,7 +2,7 @@ import express from 'express' | |||
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import LRUCache from 'lru-cache' | 3 | import LRUCache from 'lru-cache' |
4 | import { basename, dirname } from 'path' | 4 | import { basename, dirname } from 'path' |
5 | import { exists, isUUIDValid } from '@server/helpers/custom-validators/misc' | 5 | import { exists, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' |
6 | import { logger } from '@server/helpers/logger' | 6 | import { logger } from '@server/helpers/logger' |
7 | import { LRU_CACHE } from '@server/initializers/constants' | 7 | import { LRU_CACHE } from '@server/initializers/constants' |
8 | import { VideoModel } from '@server/models/video/video' | 8 | import { VideoModel } from '@server/models/video/video' |
@@ -60,7 +60,14 @@ const ensureCanAccessVideoPrivateWebTorrentFiles = [ | |||
60 | ] | 60 | ] |
61 | 61 | ||
62 | const ensureCanAccessPrivateVideoHLSFiles = [ | 62 | const ensureCanAccessPrivateVideoHLSFiles = [ |
63 | query('videoFileToken').optional().custom(exists), | 63 | query('videoFileToken') |
64 | .optional() | ||
65 | .custom(exists), | ||
66 | |||
67 | query('reinjectVideoFileToken') | ||
68 | .optional() | ||
69 | .customSanitizer(toBooleanOrNull) | ||
70 | .isBoolean().withMessage('Should be a valid reinjectVideoFileToken boolean'), | ||
64 | 71 | ||
65 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 72 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
66 | if (areValidationErrors(req, res)) return | 73 | if (areValidationErrors(req, res)) return |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 50327b6ae..64bd9ca70 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -44,7 +44,7 @@ const usersListValidator = [ | |||
44 | query('blocked') | 44 | query('blocked') |
45 | .optional() | 45 | .optional() |
46 | .customSanitizer(toBooleanOrNull) | 46 | .customSanitizer(toBooleanOrNull) |
47 | .isBoolean().withMessage('Should be a valid blocked boolena'), | 47 | .isBoolean().withMessage('Should be a valid blocked boolean'), |
48 | 48 | ||
49 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 49 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
50 | if (areValidationErrors(req, res)) return | 50 | if (areValidationErrors(req, res)) return |