Pascal Bleser
a7789f8462
graph: rate limit the personal data export
...
Each personal data export collects all events of the user and writes
them into the user's personal space, so starting exports over and over
puts load on the system. Limit how many exports a user can start to 5
per minute, configurable with GRAPH_EXPORT_PERSONAL_DATA_RATE_LIMIT
(0 disables the limit). Requests beyond it get a 429 with a
Retry-After header.
The limit uses a new middleware, RateLimitPerAuthenticatedUser. It
counts requests by the id of the authenticated user rather than by the
URL, so that variations of the URL, such as a trailing slash, can't get
around it. It comes after the check that users only export their own
data, so that requests for other users don't count against any limit.
The counters are kept in memory by every instance of the graph service.
This adds the dependency github.com/go-chi/httprate v0.16.1 (MIT), from
the authors of the chi router that the service already uses. It is used
instead of a limiter of our own, because counting requests in sliding
time windows correctly under concurrency is easy to get wrong, and the
library is maintained and tested for exactly that. It brings no further
modules: the two it needs are already required. There are no known
vulnerabilities in it, and govulncheck reports none.
Assisted-by: Claude Code:claude-opus-5-5
2026-11-13 18:25:47 +01:00
..
2024-10-18 17:35:30 +02:00
2023-04-19 20:24:34 +02:00
2023-12-14 12:10:37 +01:00
2023-04-19 20:24:34 +02:00
2026-09-23 09:54:35 +02:00
2025-01-21 11:16:38 +01:00
2024-02-21 10:20:36 +01:00
2026-10-01 11:14:15 +02:00
2023-04-21 09:09:59 +02:00
2026-10-28 09:24:42 +01:00
2023-04-19 20:24:34 +02:00
2026-10-01 11:14:15 +02:00
2026-05-20 00:37:30 +00:00
2026-08-31 13:24:49 +02:00
2023-04-19 20:24:34 +02:00
2023-04-21 09:09:59 +02:00
2026-01-21 08:43:08 +01:00
2025-09-09 15:10:28 +02:00
2024-07-10 06:19:45 +00:00
2023-04-19 20:24:34 +02:00
2025-05-12 08:21:17 +00:00
2026-07-14 13:15:54 +02:00
2026-10-01 11:14:15 +02:00
2026-10-01 11:14:15 +02:00
2026-10-01 11:14:15 +02:00
2023-12-12 19:29:18 +01:00
2025-08-28 09:32:26 +02:00
2023-10-17 21:44:43 +02:00
2026-04-24 14:50:00 +02:00
2026-10-01 11:14:15 +02:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2026-06-16 08:40:16 +00:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2024-10-18 17:35:30 +02:00
2025-08-28 09:32:26 +02:00
2026-07-14 13:15:54 +02:00
2026-08-18 15:51:36 +02:00
2023-09-07 10:53:48 +02:00
2023-04-19 20:24:34 +02:00
2026-08-18 15:51:36 +02:00
2025-09-30 15:42:51 +02:00
2023-04-19 20:24:34 +02:00
2025-08-21 11:01:12 +02:00
2026-10-01 11:14:15 +02:00
2026-07-14 13:15:54 +02:00
2026-08-18 09:43:19 +02:00
2026-06-16 08:40:16 +00:00
2026-08-03 10:44:05 +02:00
2023-04-19 20:24:34 +02:00
2023-12-20 12:33:13 +01:00
2026-10-01 11:14:15 +02:00
2026-08-03 12:16:16 +02:00
2026-11-13 18:25:47 +01:00
2026-08-14 10:40:59 +02:00
2026-11-12 11:13:35 +01:00
2023-04-19 20:24:34 +02:00
2026-11-03 18:36:26 +01:00
2023-04-21 09:09:59 +02:00
2026-08-03 17:00:51 +02:00
2025-01-21 11:16:38 +01:00
2026-08-18 15:51:36 +02:00
2026-11-12 11:11:30 +01:00
2023-04-19 20:24:34 +02:00
2026-02-17 16:51:33 +01:00
2026-10-01 11:14:15 +02:00
2024-04-30 09:59:04 +02:00
2026-06-09 17:36:19 +02:00
2026-10-06 13:46:22 +00:00
2026-06-24 14:44:07 +00:00
2026-10-01 11:14:15 +02:00
2026-05-20 00:37:30 +00:00
2026-02-05 12:29:10 +01:00
2026-10-01 11:14:15 +02:00
2026-07-06 17:48:24 +02:00
2026-10-01 11:14:15 +02:00
2026-10-28 09:25:43 +01:00
2026-08-18 15:25:23 +02:00
2024-10-18 17:35:30 +02:00
2024-02-21 10:20:36 +01:00
2026-10-01 11:14:15 +02:00
2023-05-16 17:25:55 +02:00
2024-08-15 11:51:16 +02:00
2023-04-19 20:24:34 +02:00
2026-07-01 09:57:45 +02:00
2023-09-15 11:31:41 +02:00
2025-04-28 13:43:21 +02:00
2026-10-01 11:14:15 +02:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2026-10-01 11:14:15 +02:00
2026-11-03 18:50:35 +01:00
2026-10-01 11:14:15 +02:00
2026-11-05 17:19:36 +01:00
2026-11-12 11:11:30 +01:00
2026-05-27 11:22:26 +02:00
2026-10-06 13:46:22 +00:00
2026-07-02 09:15:58 +02:00
2023-04-19 20:24:34 +02:00
2026-08-18 15:51:36 +02:00
2025-08-28 09:32:26 +02:00
2026-07-14 13:15:54 +02:00
2023-04-19 20:24:34 +02:00
2026-10-01 11:14:15 +02:00
2023-04-19 20:24:34 +02:00
2024-08-26 15:35:15 +02:00
2024-06-03 08:57:54 +02:00
2026-10-01 11:14:15 +02:00
2024-10-18 17:35:30 +02:00
2026-07-14 13:15:54 +02:00
2026-06-09 17:36:19 +02:00
2024-09-25 10:45:29 +02:00
2026-10-01 11:14:15 +02:00
2025-12-18 13:33:02 +01:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2024-08-21 08:48:22 +02:00
2026-11-05 17:20:10 +01:00
2024-02-02 09:22:22 +01:00
2026-10-01 11:14:15 +02:00
2025-06-30 17:46:21 +00:00
2026-10-06 13:46:22 +00:00
2026-10-28 14:49:11 +01:00
2026-10-06 13:46:22 +00:00
2026-11-13 15:21:45 +01:00
2025-08-28 09:32:26 +02:00
2026-08-26 11:51:05 +02:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2026-06-09 17:36:19 +02:00
2023-04-19 20:24:34 +02:00
2024-01-29 12:30:34 +01:00
2026-07-14 13:15:54 +02:00
2025-06-05 15:23:58 +02:00
2026-07-14 13:15:54 +02:00
2026-05-13 14:39:31 +02:00
2025-07-01 14:26:32 +00:00
2023-04-19 20:24:34 +02:00
2026-03-11 11:55:40 +01:00
2024-05-08 17:57:35 +02:00
2026-11-05 17:20:56 +01:00
2026-10-01 11:14:15 +02:00
2023-06-29 14:04:38 +02:00
2025-09-29 11:13:42 +02:00
2026-05-21 16:18:29 +00:00
2026-05-20 00:37:30 +00:00
2025-01-21 14:59:36 +00:00
2026-06-23 14:43:53 +00:00
2026-03-23 16:14:30 +01:00
2023-04-19 20:24:34 +02:00
2025-10-23 17:48:43 +02:00
2025-12-15 16:40:26 +01:00
2026-04-08 11:45:37 +02:00
2026-07-14 13:15:54 +02:00
2024-07-30 16:14:19 +02:00
2025-09-23 10:28:55 +02:00
2026-08-03 17:43:51 +02:00
2026-10-28 14:48:53 +01:00
2026-08-18 15:51:36 +02:00
2026-10-01 11:14:15 +02:00
2026-10-01 11:14:15 +02:00
2025-12-15 16:40:26 +01:00
2023-04-19 20:24:34 +02:00
2026-01-14 16:46:02 +01:00
2026-08-25 09:32:01 +02:00
2025-01-07 13:52:18 +01:00
2025-12-15 16:40:26 +01:00
2025-09-23 10:28:55 +02:00
2025-06-05 15:23:58 +02:00
2026-08-18 15:51:36 +02:00
2024-12-03 09:09:07 +01:00
2026-10-29 09:26:38 +01:00
2026-01-21 08:43:08 +01:00
2026-08-18 15:51:36 +02:00
2023-04-19 20:24:34 +02:00
2023-04-19 20:24:34 +02:00
2026-03-24 18:46:25 +01:00
2026-03-12 11:54:26 +01:00
2025-12-18 13:33:02 +01:00
2026-06-16 08:40:16 +00:00
2026-10-06 13:46:22 +00:00
2025-05-16 10:24:43 +02:00
2023-04-19 20:24:34 +02:00
2023-12-27 15:14:52 +00:00
2023-04-19 20:24:34 +02:00
2023-08-29 17:31:47 +02:00
2026-10-01 11:14:15 +02:00
2023-12-05 09:47:11 +01:00
2025-08-28 09:32:26 +02:00
2026-05-11 17:08:39 +02:00