-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
I'm using the following RateLimit for the Route of one of my controllers:
@RateLimit(methods={"PUT", "POST"}, limit=35, period=3600)
and use the following storage backend:
## config/services.yaml
rate_limit_cache_storage:
class: Symfony\Component\Cache\Simple\FilesystemCache
arguments: ['ratelimit', 0, '%kernel.cache_dir%']
## config/packages/noxlogic_rate_limit.yaml
noxlogic_rate_limit:
storage_engine: simple_cache
simple_cache_service: rate_limit_cache_storage
rate_response_code: 429
rate_response_message: 'You exceeded the rate limit'Sadly, once I started getting IPv6 flowing my controller started failing badly:
Uncaught PHP Exception Symfony\Component\Cache\Exception\InvalidArgumentException:
"Cache key "PUT.POST.api_foo.2800:xxx:yyyy:zzzz:d141:zzzz:xxx:yyyy" contains reserved characters "{}()/\@:"." at
vendor/symfony/cache/CacheItem.php line 177
{"exception":"[object] (Symfony\\Component\\Cache\\Exception\\InvalidArgumentException(code: 0): Cache key \"PUT.POST.api_foo.2800:xxx:yyyy:zzzz:d141:zzzz:xxx:yyyy\" contains reserved characters \"{}()/\\@:\". at vendor/symfony/cache/CacheItem.php:177)"} []
This is really bad because:
- This basically kept requests from fullfiling even though such an exceptions must have failed safely (A failure of the RateLimit is not something that must block normal processing!).
- I've no (simple) way to create filesystem-compatible cache-key for IPv6 without rolling a custom cache-key generator.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels