aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-26 16:23:39 +0200
committerChocobozzz <me@florianbigard.com>2022-10-27 09:13:10 +0200
commit5a122dddc5aab1b2ae1843411032d5f392bdd216 (patch)
tree39778c4372c4b371f1294c94bf22d8a6e7a26456 /server/middlewares
parent49e7e4d9ffd16cba7a721f6d3d3203decf4f4b2c (diff)
downloadPeerTube-5a122dddc5aab1b2ae1843411032d5f392bdd216.tar.gz
PeerTube-5a122dddc5aab1b2ae1843411032d5f392bdd216.tar.zst
PeerTube-5a122dddc5aab1b2ae1843411032d5f392bdd216.zip
Option to disable static files auth check/s3 proxy
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/index.ts1
-rw-r--r--server/middlewares/validators/object-storage-proxy.ts20
2 files changed, 21 insertions, 0 deletions
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'
11export * from './jobs' 11export * from './jobs'
12export * from './logs' 12export * from './logs'
13export * from './metrics' 13export * from './metrics'
14export * from './object-storage-proxy'
14export * from './oembed' 15export * from './oembed'
15export * from './pagination' 16export * from './pagination'
16export * from './plugins' 17export * 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 @@
1import express from 'express'
2import { CONFIG } from '@server/initializers/config'
3import { HttpStatusCode } from '@shared/models'
4
5const ensurePrivateObjectStorageProxyIsEnabled = [
6 (req: express.Request, res: express.Response, next: express.NextFunction) => {
7 if (CONFIG.OBJECT_STORAGE.PROXY.PROXIFY_PRIVATE_FILES !== true) {
8 return res.fail({
9 message: 'Private object storage proxy is not enabled',
10 status: HttpStatusCode.BAD_REQUEST_400
11 })
12 }
13
14 return next()
15 }
16]
17
18export {
19 ensurePrivateObjectStorageProxyIsEnabled
20}