diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-04 16:42:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-04 16:42:40 +0200 |
commit | c1340a6ac35f924161e6ec2a1d728e20c89e55c8 (patch) | |
tree | 8f0a6b72b36be586422002039720d3a08309cbea /server/initializers | |
parent | fd0bfc3ac43eb0c0c2ac0b21bc2e0670f546384f (diff) | |
download | PeerTube-c1340a6ac35f924161e6ec2a1d728e20c89e55c8.tar.gz PeerTube-c1340a6ac35f924161e6ec2a1d728e20c89e55c8.tar.zst PeerTube-c1340a6ac35f924161e6ec2a1d728e20c89e55c8.zip |
Add rate limit to registration and API endpoints
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/config.ts | 8 | ||||
-rw-r--r-- | server/initializers/constants.ts | 14 |
2 files changed, 8 insertions, 14 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index bb278ba43..eefb45fb9 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -72,6 +72,14 @@ const CONFIG = { | |||
72 | PORT: config.get<number>('webserver.port') | 72 | PORT: config.get<number>('webserver.port') |
73 | }, | 73 | }, |
74 | RATES_LIMIT: { | 74 | RATES_LIMIT: { |
75 | API: { | ||
76 | WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.api.window')), | ||
77 | MAX: config.get<number>('rates_limit.api.max') | ||
78 | }, | ||
79 | SIGNUP: { | ||
80 | WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.signup.window')), | ||
81 | MAX: config.get<number>('rates_limit.signup.max') | ||
82 | }, | ||
75 | LOGIN: { | 83 | LOGIN: { |
76 | WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.login.window')), | 84 | WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.login.window')), |
77 | MAX: config.get<number>('rates_limit.login.max') | 85 | MAX: config.get<number>('rates_limit.login.max') |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 500f8770a..abd9c2003 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -280,17 +280,6 @@ let CONSTRAINTS_FIELDS = { | |||
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | const RATES_LIMIT = { | ||
284 | LOGIN: { | ||
285 | WINDOW_MS: CONFIG.RATES_LIMIT.LOGIN.WINDOW_MS, | ||
286 | MAX: CONFIG.RATES_LIMIT.LOGIN.MAX | ||
287 | }, | ||
288 | ASK_SEND_EMAIL: { | ||
289 | WINDOW_MS: CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.WINDOW_MS, | ||
290 | MAX: CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.MAX | ||
291 | } | ||
292 | } | ||
293 | |||
294 | let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour | 283 | let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour |
295 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour | 284 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour |
296 | 285 | ||
@@ -624,8 +613,6 @@ if (isTestInstance() === true) { | |||
624 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | 613 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
625 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 | 614 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 |
626 | ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms' | 615 | ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms' |
627 | |||
628 | RATES_LIMIT.LOGIN.MAX = 20 | ||
629 | } | 616 | } |
630 | 617 | ||
631 | updateWebserverUrls() | 618 | updateWebserverUrls() |
@@ -696,7 +683,6 @@ export { | |||
696 | SCHEDULER_INTERVALS_MS, | 683 | SCHEDULER_INTERVALS_MS, |
697 | REPEAT_JOBS, | 684 | REPEAT_JOBS, |
698 | STATIC_DOWNLOAD_PATHS, | 685 | STATIC_DOWNLOAD_PATHS, |
699 | RATES_LIMIT, | ||
700 | MIMETYPES, | 686 | MIMETYPES, |
701 | CRAWL_REQUEST_CONCURRENCY, | 687 | CRAWL_REQUEST_CONCURRENCY, |
702 | DEFAULT_AUDIO_RESOLUTION, | 688 | DEFAULT_AUDIO_RESOLUTION, |