mirror of
https://github.com/strapi/strapi.git
synced 2025-10-30 01:17:28 +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) => {
|
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.';
|
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,
|
interval: 1*60*1000,
|
||||||
max: 5,
|
max: 5,
|
||||||
prefixKey: `${ctx.request.url}:${ctx.request.ip}`,
|
prefixKey: `${ctx.request.url}:${ctx.request.ip}`,
|
||||||
message
|
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