Skip to content

Commit 2e1cc43

Browse files
authored
Add rate limiting documentation for users-permissions plugin (#2782)
1 parent 95574ca commit 2e1cc43

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

docusaurus/docs/cms/features/users-permissions.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,68 @@ export default ({ env }) => ({
346346

347347
</Tabs>
348348

349+
### Rate limiting configuration
350+
351+
Rate limiting is applied to authentication and registration endpoints to prevent abuse. The following parameters can be configured to change its behavior. Additional configuration options are provided by the <ExternalLink text="koa2-ratelimit" to="https://github.com/ysocorp/koa2-ratelimit?tab=readme-ov-file#configuration"/> package:
352+
353+
354+
The following options are available in [the `/config/plugins` file](/cms/configurations/plugins):
355+
356+
| Parameter | Description | Type | Default |
357+
| --------- | ----------- | ---- | ------- |
358+
| `ratelimit` | Settings to customize the rate limiting of the authentications and registration endpoints | object | `{}` |
359+
| `ratelimit.enabled` | Enable or disable the rate limiter | boolean | `true` |
360+
| `ratelimit.interval` | Time window for requests to be considered as part of the same rate limiting bucket | object | `{ min: 5 }` |
361+
| `ratelimit.max` | Maximum number of requests allowed in the time window | integer | `5` |
362+
| `ratelimit.prefixKey` | Prefix for the rate limiting key | string | `${userIdentifier}:${requestPath}:${ctx.request.ip}` |
363+
364+
365+
<Tabs groupId="js-ts">
366+
367+
<TabItem value="javascript" label="JavaScript">
368+
369+
```js title="/config/plugins.js"
370+
module.exports = ({ env }) => ({
371+
// ... other plugins configuration ...
372+
// Users & Permissions configuration
373+
'users-permissions': {
374+
config: {
375+
ratelimit: {
376+
enabled: true,
377+
interval: { min: 5 },
378+
max: 5,
379+
},
380+
},
381+
},
382+
// ...
383+
});
384+
```
385+
386+
</TabItem>
387+
388+
<TabItem value="typescript" label="TypeScript">
389+
390+
```ts title="/config/plugins.ts"
391+
export default ({ env }) => ({
392+
// ... other plugins configuration ...
393+
// Users & Permissions configuration
394+
'users-permissions': {
395+
config: {
396+
ratelimit: {
397+
enabled: true,
398+
interval: { min: 5 },
399+
max: 5,
400+
},
401+
},
402+
},
403+
// ...
404+
});
405+
```
406+
407+
</TabItem>
408+
409+
</Tabs>
410+
349411
### Templating emails
350412

351413
By default this plugin comes with two templates: reset password and email address confirmation. The templates use <ExternalLink to="https://lodash.com/docs/4.17.15#template" text="Lodash's `template()` method"/> to populate the variables.

0 commit comments

Comments
 (0)