dmt-software / anti-xss-middleware
PSR-15 middleware to help prevent xss attacks
Installs: 8 569
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- psr/http-factory: ^1.0
- psr/http-message: >=1.0
- psr/http-server-middleware: ^1.0
- voku/anti-xss: ^4.1
Requires (Dev)
- guzzlehttp/psr7: ^2.2
- phpunit/phpunit: ^9.5
README
This middleware implements the PSR-15 MiddlewareInterface and can be helpful to prevent XSS attacks.
Installation
composer require dmt-software/anti-xss-middleware
Usage
use DMT\Http\AntiXss\Middleware\AntiXssMiddleware; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; /** @var ResponseFactoryInterface $responseFactory */ $antiXssMiddleware = new AntiXssMiddleware($responseFactory); /** @var ServerRequestInterface $request */ /** @var RequestHandlerInterface $handler */ $response = $antiXssMiddleware->process($request, $handler); if ($response->getStatusCode() === 400) { // cross site scripting detected }