From 5a122dddc5aab1b2ae1843411032d5f392bdd216 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 26 Oct 2022 16:23:39 +0200 Subject: Option to disable static files auth check/s3 proxy --- server/controllers/static.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'server/controllers/static.ts') diff --git a/server/controllers/static.ts b/server/controllers/static.ts index dc091455a..6ef9154b9 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -15,11 +15,17 @@ const staticRouter = express.Router() // Cors is very important to let other servers access torrent and video files staticRouter.use(cors()) +// --------------------------------------------------------------------------- // WebTorrent/Classic videos +// --------------------------------------------------------------------------- + +const privateWebTorrentStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUIRE_AUTH === true + ? [ optionalAuthenticate, asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles) ] + : [] + staticRouter.use( STATIC_PATHS.PRIVATE_WEBSEED, - optionalAuthenticate, - asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles), + ...privateWebTorrentStaticMiddlewares, express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), handleStaticError ) @@ -35,11 +41,17 @@ staticRouter.use( handleStaticError ) +// --------------------------------------------------------------------------- // HLS +// --------------------------------------------------------------------------- + +const privateHLSStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUIRE_AUTH === true + ? [ optionalAuthenticate, asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles) ] + : [] + staticRouter.use( STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, - optionalAuthenticate, - asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles), + ...privateHLSStaticMiddlewares, express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }), handleStaticError ) -- cgit v1.2.3