discourse/lib/middleware
Alan Guo Xiang Tan 859d61003e
DEV: API to register custom request rate limiting conditions (#30239)
This commit adds the `add_request_rate_limiter` plugin API which allows plugins to add custom rate limiters on top of the default rate limiters which requests by a user's id or the request's IP address.

Example to add a rate limiter that rate limits all requests from Googlebot under the same rate limit bucket:

```
add_request_rate_limiter(
  identifier: :country,
  key: ->(request) { "country/#{DiscourseIpInfo.get(request.ip)[:country]}" },
  activate_when: ->(request) { DiscourseIpInfo.get(request.ip)[:country].present? },
)
```
2024-12-23 09:57:18 +08:00
..
anonymous_cache.rb DEV: add the notion of a 'crawler identifier' in anonymous_cache 2024-12-09 13:40:22 -05:00
csp_script_nonce_injector.rb DEV: Memoize CSP nonce placeholder on response (#25724) 2024-02-16 12:15:55 +00:00
discourse_public_exceptions.rb DEV: Upgrade Rails to version 7.1 2024-07-04 10:58:21 +02:00
enforce_hostname.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
missing_avatars.rb DEV: Prefer \A and \z over ^ and $ in regexes (#19936) 2023-01-20 12:52:49 -06:00
omniauth_bypass_middleware.rb DEV: Relax auth provider registration restrictions for plugins (#24095) 2023-10-26 10:54:30 +01:00
processing_request.rb FIX: Set sane default for Net::HTTP when processing a request (#28141) 2024-08-06 07:12:42 +08:00
request_tracker.rb DEV: API to register custom request rate limiting conditions (#30239) 2024-12-23 09:57:18 +08:00
turbo_dev.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00