Commit Graph
14 Commits
Author SHA1 Message Date
Pascal Bleser 0169f3b0a5 graph: answer the export rate limit in the graph error format
A request to export the personal data beyond the rate limit got the
plain text 429 of httprate, while the other errors of graph, also those
of the same route, are JSON with an error code.

RateLimitPerAuthenticatedUser takes a handler for the response beyond
the limit now, so that a service can answer in its own format; nil
keeps the plain text 429. Graph answers with activityLimitReached. The
Retry-After header is set before the handler is called, so it stays.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-13 18:25:47 +01:00
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
Alex Ababii 3fb1dd3f3f Merge pull request #3938 from maki5/fix/webfinger_panic
fix(webfinger): fix panic in OidcAuth middleware
2026-11-11 10:54:33 +01:00
Jörn Friedrich Dreyer 73bfeb00d0 fix(middleware): do not build the XFF middleware without trusted proxies
Starting with chi v5.4.0, ClientIPFromXFF panics when no trusted prefix
is given, so ClientIP would crash the proxy and collaboration services at
startup when no trusted proxies are configured. Without trusted proxies
every request uses the network address anyway, so return
ClientIPFromRemoteAddr.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-11-10 13:00:28 +01:00
Alex Ababii c71ca6f699 fix(webfinger): fix panic in OidcAuth middleware 2026-11-09 14:33:55 +01:00
micbar b7bb4fbe8c fix: client address for clients in a private network and behind the proxy 2026-11-02 10:25:18 +01:00
micbar 4e7ebd4f8c fix: only trust forwarding headers from trusted reverse proxies
chi's ClientIPFrom* header middlewares trust the header from anyone who can
  reach us. Pick the middleware per request instead: headers are only read
  when the peer is a trusted proxy, everyone else gets their network address.

  - PROXY_TRUSTED_PROXIES, defaults to loopback and private ranges
  - PROXY_CLIENT_IP_HEADER, defaults to X-Forwarded-For, e.g. CF-Connecting-IP
  - drop the strategy setting and xff_trusted_hops
  - pass the client address to the services in X-Forwarded-For instead of
    X-Client-Ip, reva reads it e.g. for OCM
  - same check in collaboration, traefik routes to it directly
  - OC_TRUSTED_PROXIES and OC_CLIENT_IP_HEADER set both services
  - the other services only drop RealIP, none of them reads the address

  Taken from #3864 and https://github.com/opencloud-eu/opencloud/pull/3464#issuecomment-6494799883

# Conflicts:
#	services/proxy/README.md
2026-10-30 15:15:22 +01:00
Alex Ababii cf0f06e060 select correct chi middleware to get real IP based on config values 2026-10-30 15:13:55 +01:00
amir 0a3378eef8 fix(middleware): reject empty OIDC providers safely 2026-08-29 19:29:18 +03:30
Florian Schade 288e67cc39 chore: replace interface with any 2026-04-23 09:31:11 +02:00
Ralf Haferkamp 95f28baa52 Use constant instead of repeating the "x-access-token" string over and over 2025-04-30 10:17:58 +02:00
André Duffeck e8d35e1280 Use the opencloud reva from now on 2025-01-21 11:16:38 +01:00
Ralf Haferkamp e07f0154bb Rebrand pkg 2025-01-20 10:59:08 +01:00
Jörn Friedrich Dreyer b07b5a1149 use plain pkg module
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 16:42:19 +01:00