Closed babeuloula closed 6 years ago
What error is throwed?
This is the subjet of the topic : Firewall middleware needs ClientIp executed before
File: .../psr7-middlewares/src/Middleware/Firewall.php:76
I don't see why are you getting this error, but suspect it's something unrelated with this package. Are you sue that ClientIp is executed before Firewall, and the request passed to Firewall has the request attribute with the ClientIp data?
Of course ClientIp is launch before. As you can see I execute ClientIp before Firewall :
$app->add(Middleware::ClientIp());
$app->add(Middleware::Firewall(['37.97.90.193']));
If you read the documentation of Slim3, you register middleware like this $app->add( new ExampleMiddleware());
I just installed and try slim and works fine. The problem is you're adding the middlewares in reverse order. Slim insert the middlewares at the begining of the stack so in your example firewall is executed before clientIp.
The opposite order should work fine:
$app->add(Middleware::Firewall(['37.97.90.193']));
$app->add(Middleware::ClientIp());
@babeuloula this behavior is descibed here: https://www.slimframework.com/docs/concepts/middleware.html#how-does-middleware-work
@oscarotero Ok I will test this tomorrow. Thanks
Hello,
I use Slim3 and I try to use the firewall but I've an error :
ClientIp has launch before Firewall. Why I've this error ?
Thanks