From 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Oct 2022 16:09:02 +0200 Subject: Put private videos under a specific subdirectory --- server/controllers/static.ts | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'server/controllers/static.ts') diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 33c429eb1..dc091455a 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,20 +1,34 @@ import cors from 'cors' import express from 'express' -import { handleStaticError } from '@server/middlewares' +import { + asyncMiddleware, + ensureCanAccessPrivateVideoHLSFiles, + ensureCanAccessVideoPrivateWebTorrentFiles, + handleStaticError, + optionalAuthenticate +} from '@server/middlewares' import { CONFIG } from '../initializers/config' -import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' +import { DIRECTORIES, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' const staticRouter = express.Router() // Cors is very important to let other servers access torrent and video files staticRouter.use(cors()) -// Videos path for webseed +// WebTorrent/Classic videos +staticRouter.use( + STATIC_PATHS.PRIVATE_WEBSEED, + optionalAuthenticate, + asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles), + express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), + handleStaticError +) staticRouter.use( STATIC_PATHS.WEBSEED, - express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }), + express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }), handleStaticError ) + staticRouter.use( STATIC_PATHS.REDUNDANCY, express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), @@ -22,9 +36,16 @@ staticRouter.use( ) // HLS +staticRouter.use( + STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, + optionalAuthenticate, + asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles), + express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }), + handleStaticError +) staticRouter.use( STATIC_PATHS.STREAMING_PLAYLISTS.HLS, - express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }), + express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, { fallthrough: false }), handleStaticError ) -- cgit v1.2.3