diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-26 16:23:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-27 09:13:10 +0200 |
commit | 5a122dddc5aab1b2ae1843411032d5f392bdd216 (patch) | |
tree | 39778c4372c4b371f1294c94bf22d8a6e7a26456 /server/middlewares | |
parent | 49e7e4d9ffd16cba7a721f6d3d3203decf4f4b2c (diff) | |
download | PeerTube-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.ts | 1 | ||||
-rw-r--r-- | server/middlewares/validators/object-storage-proxy.ts | 20 |
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' | |||
11 | export * from './jobs' | 11 | export * from './jobs' |
12 | export * from './logs' | 12 | export * from './logs' |
13 | export * from './metrics' | 13 | export * from './metrics' |
14 | export * from './object-storage-proxy' | ||
14 | export * from './oembed' | 15 | export * from './oembed' |
15 | export * from './pagination' | 16 | export * from './pagination' |
16 | export * from './plugins' | 17 | 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 @@ | |||
1 | import express from 'express' | ||
2 | import { CONFIG } from '@server/initializers/config' | ||
3 | import { HttpStatusCode } from '@shared/models' | ||
4 | |||
5 | const 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 | |||
18 | export { | ||
19 | ensurePrivateObjectStorageProxyIsEnabled | ||
20 | } | ||