Add rate limit configs

This commit is contained in:
Jim LAURIE 2018-08-08 14:29:10 +02:00
parent 738cbf656a
commit 0afe2eceac
2 changed files with 8 additions and 2 deletions

View File

@ -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);
};

View File

@ -0,0 +1,6 @@
{
"ratelimit": {
"interval": 60000,
"max": 10
}
}