From 71e3e879c0616882ee82a0e44f8c2e5ee9698a3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 2 Dec 2022 14:47:21 +0100 Subject: Support reinjecting token in private m3u8 playlist --- server/middlewares/validators/static.ts | 11 +++++++++-- server/middlewares/validators/users.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'server/middlewares/validators') 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' import { query } from 'express-validator' import LRUCache from 'lru-cache' import { basename, dirname } from 'path' -import { exists, isUUIDValid } from '@server/helpers/custom-validators/misc' +import { exists, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' import { logger } from '@server/helpers/logger' import { LRU_CACHE } from '@server/initializers/constants' import { VideoModel } from '@server/models/video/video' @@ -60,7 +60,14 @@ const ensureCanAccessVideoPrivateWebTorrentFiles = [ ] const ensureCanAccessPrivateVideoHLSFiles = [ - query('videoFileToken').optional().custom(exists), + query('videoFileToken') + .optional() + .custom(exists), + + query('reinjectVideoFileToken') + .optional() + .customSanitizer(toBooleanOrNull) + .isBoolean().withMessage('Should be a valid reinjectVideoFileToken boolean'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { 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 = [ query('blocked') .optional() .customSanitizer(toBooleanOrNull) - .isBoolean().withMessage('Should be a valid blocked boolena'), + .isBoolean().withMessage('Should be a valid blocked boolean'), (req: express.Request, res: express.Response, next: express.NextFunction) => { if (areValidationErrors(req, res)) return -- cgit v1.2.3