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/middlewares/validators/index.ts | 1 + .../middlewares/validators/object-storage-proxy.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 server/middlewares/validators/object-storage-proxy.ts (limited to 'server/middlewares') diff --git a/server/middlewares/validators/index.ts b/server/middlewares/validators/index.ts index 899da229a..9bc8887ff 100644 --- a/server/middlewares/validators/index.ts +++ b/server/middlewares/validators/index.ts @@ -11,6 +11,7 @@ export * from './follows' export * from './jobs' export * from './logs' export * from './metrics' +export * from './object-storage-proxy' export * from './oembed' export * from './pagination' export * from './plugins' diff --git a/server/middlewares/validators/object-storage-proxy.ts b/server/middlewares/validators/object-storage-proxy.ts new file mode 100644 index 000000000..bbd77f262 --- /dev/null +++ b/server/middlewares/validators/object-storage-proxy.ts @@ -0,0 +1,20 @@ +import express from 'express' +import { CONFIG } from '@server/initializers/config' +import { HttpStatusCode } from '@shared/models' + +const ensurePrivateObjectStorageProxyIsEnabled = [ + (req: express.Request, res: express.Response, next: express.NextFunction) => { + if (CONFIG.OBJECT_STORAGE.PROXY.PROXIFY_PRIVATE_FILES !== true) { + return res.fail({ + message: 'Private object storage proxy is not enabled', + status: HttpStatusCode.BAD_REQUEST_400 + }) + } + + return next() + } +] + +export { + ensurePrivateObjectStorageProxyIsEnabled +} -- cgit v1.2.3