**Silverstripe Version: 4.13 **
Rate limit implementation on a PageController
Tried to follow the developer guide to implement a rate limit on a form submission, following
using
SilverStripe\Core\Injector\Injector:
MyRateLimitMiddleware:
class: SilverStripe\Control\Middleware\RateLimitMiddleware
properties:
ExtraKey: 'mylimiter' # this isolates your rate limiter from others
MaxAttempts: 10 # how many attempts are allowed in a decay period
Decay: 1 # how long the decay period is in minutes
SilverStripe\Core\Injector\Injector:
MyRateLimitedController:
class: SilverStripe\Control\Middleware\RequestHandlerMiddlewareAdapter
properties:
RequestHandler: '%$PageController' # the fully qualified class name of your controller
Middlewares:
- '%$MyRateLimitMiddleware' # the rate limiter we just defined in the last step
I’ve set the RequestHandler: '%$PageController'
where PageController
is where I have the form submission handling, the for is submited to an action on that controller.
I’ve also tried to apply the middleware to a specific route, but without success.
Also I’ve put a debug::show
under RateLimitMiddleware
, and it does not get called.
Did anyone use it?
I’ve manage to develop a rate limit inside the form handling, but it’s not the best solution.
Thanks in advance