Make ratelimits configurable - #3090
Conversation
|
@felix-m-c and I discussed about this.
|
|
Hello, I will need to think about whether these should be configured from code config or UI config but I'm more curious about the underlying issue. I believe that the ratelimit applies to IP address and code so what was the issue caused by the shared IP? Were all of the users also sharing the same account?
|
|
Hello @ColdHeat , thanks for the quick reply, all our cases use different accounts.
|
|
The Ratelimiter uses the Cache System to track the number of accesses over time. Not tying access counters to usernames/emails makes sense because many rate-limited endpoints would be called before login. (/login, /register, /reset_password, /redirect) For some of these, we could add another identifier to the cache key, but that would be some user-provided (untrusted) string that someone trying to overwhelm the system could just randomize anyways. (e.g., the requested email adress for /reset_password). (i would also like to mention here that the rate-limiting logic does not limit users to N accesses over M seconds, but instead it counts until N and only resets if a gap of M seconds occurred in between. E.g., 1 access every 50 seconds would trigger a (limit=10, interval=60) configuration after 500 Seconds) |
|
I agree that this should be implemented via config.ini/config.py. The names of the variables should be Also instead of hardcoding the values in config.ini I think it would be better to set them in config.py so that it's easier for an envvar to override. |
Summary:
currently, it is not possible to configure or disable the ratelimit system.
This poses an issue for our events where many (30+) users may share a single IP address.
In these cases features like flag submission immediately run into rate limits for all users.
This issue was previously discussed in #1091, but did not lead to a PR at the time.
Change:
This PR moves the configuration of rate limits from the sourcecode to the config.ini file. (excerpt see below)
It also adds a new RL_DISABLE_COMPLETELY option that disables ratelimits outright.
Backwards Compatibility:
Plugins using the syntax
@ratelimit(method="POST", limit=10, interval=60)still work because I only add (optional!) keyword args. If these Values are provided, the new logic uses them instead of falling back toRL_DEFAULT.The decorator
@ratelimit(method="POST")now uses the configured default ratelimit.Note that the
RL_DISABLE_COMPLETELYconfig option overrides the ratelimit decorator for exiing plugins too.