You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration.md
+42-1Lines changed: 42 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,11 @@ The following skeleton shows **every** configuration option at a glance. Require
55
55
"roles": ["Admin", "User"], // optional
56
56
"generateLoginEndpoint": true, // default: true
57
57
"generateRegisterEndpoint": true// default: true
58
+
},
59
+
"rateLimit": {
60
+
"permitLimit": 100, // default: 100
61
+
"windowSeconds": 60, // default: 60
62
+
"segmentsPerWindow": 6// default: 6
58
63
}
59
64
},
60
65
"enums": {
@@ -118,7 +123,8 @@ The `config` object contains project-level settings.
118
123
"cors": { ... },
119
124
"features": { ... },
120
125
"database": { ... },
121
-
"auth": { ... }
126
+
"auth": { ... },
127
+
"rateLimit": { ... }
122
128
}
123
129
}
124
130
```
@@ -212,6 +218,36 @@ When auth is enabled:
212
218
{: .note }
213
219
> When the `auth` block is absent, all endpoints use `AllowAnonymous()` and no auth infrastructure is generated. This is fully backward-compatible.
214
220
221
+
### Rate Limiting
222
+
223
+
The optional `rateLimit` object enables ASP.NET Core's built-in sliding window rate limiter for the generated API.
224
+
225
+
```json
226
+
{
227
+
"config": {
228
+
"rateLimit": {
229
+
"permitLimit": 100,
230
+
"windowSeconds": 60,
231
+
"segmentsPerWindow": 6
232
+
}
233
+
}
234
+
}
235
+
```
236
+
237
+
| Field | Type | Default | Description |
238
+
|---|---|---|---|
239
+
|`permitLimit`|`integer`|`100`| Maximum number of requests allowed within the time window. |
240
+
|`windowSeconds`|`integer`|`60`| Duration of the time window in seconds. |
241
+
|`segmentsPerWindow`|`integer`|`6`| Number of segments the window is divided into for smoother rate limiting. |
242
+
243
+
When rate limiting is enabled:
244
+
- Requests exceeding the limit receive a `429 Too Many Requests` response
245
+
- The rate limiter middleware is added after CORS and before authentication in the pipeline
246
+
- A named policy `"sliding"` is registered and applied globally
247
+
248
+
{: .note }
249
+
> When the `rateLimit` block is absent, no rate limiting infrastructure is generated. This is fully backward-compatible.
250
+
215
251
## Entities
216
252
217
253
The `entities` object is a dictionary where each key is an entity name (PascalCase) and each value describes its properties and optional relationships and seed data.
@@ -401,6 +437,11 @@ A full `ninjadog.json` demonstrating all features:
0 commit comments