mirror of
https://github.com/strapi/strapi.git
synced 2025-10-29 00:49:49 +00:00
Add rate limit configs
This commit is contained in:
parent
738cbf656a
commit
0afe2eceac
@ -3,10 +3,10 @@ const RateLimit = require('koa2-ratelimit').RateLimit;
|
||||
module.exports = async (ctx, next) => {
|
||||
const message = ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.ratelimit' }] }] : 'Too many attempts, please try again in a minute.';
|
||||
|
||||
return RateLimit.middleware({
|
||||
return RateLimit.middleware(Object.assign({}, {
|
||||
interval: 1*60*1000,
|
||||
max: 5,
|
||||
prefixKey: `${ctx.request.url}:${ctx.request.ip}`,
|
||||
message
|
||||
})(ctx, next);
|
||||
}, strapi.plugins['users-permissions'].config.ratelimit))(ctx, next);
|
||||
};
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"ratelimit": {
|
||||
"interval": 60000,
|
||||
"max": 10
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user