mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Add rate-limiting to new password change endpoint
This commit is contained in:
parent
9076fddc0d
commit
1493cacb69
@ -1,5 +1,6 @@
|
||||
const { Context } = require("../../util/context");
|
||||
const { asyncSafeSetInterval } = require("../../util/promise");
|
||||
const { quot } = require("../../util/strutil");
|
||||
|
||||
const { MINUTE, HOUR } = require('../../util/time.js');
|
||||
const BaseService = require("../BaseService");
|
||||
@ -55,6 +56,10 @@ class EdgeRateLimitService extends BaseService {
|
||||
limit: 10,
|
||||
window: HOUR,
|
||||
},
|
||||
['/user-protected/change-password']: {
|
||||
limit: 10,
|
||||
window: HOUR,
|
||||
},
|
||||
['login-otp']: {
|
||||
limit: 15,
|
||||
window: 30 * MINUTE,
|
||||
@ -77,6 +82,9 @@ class EdgeRateLimitService extends BaseService {
|
||||
}
|
||||
|
||||
check (scope) {
|
||||
if ( ! this.scopes.hasOwnProperty(scope) ) {
|
||||
throw new Error(`unrecognized rate-limit scope: ${quot(scope)}`)
|
||||
}
|
||||
const { window, limit } = this.scopes[scope];
|
||||
|
||||
const requester = Context.get('requester');
|
||||
|
Loading…
Reference in New Issue
Block a user