PHP Framework Symfony
Requirements
Installation & Configuration
1
Install Zen Firewall by Aikido
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/latest/download/aikido-php-firewall.x86_64.rpmrpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/latest/download/aikido-php-firewall.aarch64.rpmcurl -L -O https://github.com/AikidoSec/firewall-php/releases/latest/download/aikido-php-firewall.x86_64.deb
dpkg -i -E ./aikido-php-firewall.x86_64.debcurl -L -O https://github.com/AikidoSec/firewall-php/releases/latest/download/aikido-php-firewall.aarch64.deb
dpkg -i -E ./aikido-php-firewall.aarch64.deb2
4
Enable Rate limiting and User blocking
namespace App\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
class AikidoMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (!extension_loaded('aikido')) {
return $handler->handle($request);
}
$decision = \aikido\should_block_request();
if ($decision->block && $decision->type == 'blocked') {
return new \Symfony\Component\HttpFoundation\Response('You are blocked by Zen.', 403);
}
if ($decision->block && $decision->type == 'ratelimited') {
return new \Symfony\Component\HttpFoundation\Response('You are rate limited by Zen.', 429);
}
return $handler->handle($request);
}
}5
Setup rate limiting in the dashboard



You are rate limited by Aikido firewall. (Your IP: 1.2.3.4)Last updated
Was this helpful?
