phpolar / csrf-protection
Provides request checking and response filtering to mitigate CSRF attacks
3.1.1
2024-12-01 21:19 UTC
Requires
- php: >=8.1
- ext-mbstring: *
- php-contrib/response-filter: ^1.0
- phpolar/http-codes: ^0.0.6
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- ext-ast: ^1.1
- ext-openssl: *
- phan/phan: ^5.4
- php-coveralls/php-coveralls: ^2.5
- phpmd/phpmd: ^2.13
- phpolar/csrf-response-filter: ^1.0
- phpolar/http-message-test-utils: ^0.2.0
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^11.1.3
- squizlabs/php_codesniffer: ^3.7
Suggests
- monolog/monolog: Allows for logging forbidden requests
- nyholm/psr7: A fast, simple PSR-7 implementation
- phpolar/csrf-response-filter: Attaches CSRF tokens to PSR-7 HTTP Responses
Provides
README
Csrf Protection
PSR-7 and PSR-15 based CSRF protection for HTTP requests
Table of Contents
Installation
composer require phpolar/csrf-protection
Usage
$csrfChecking = $this->container->get(CsrfRequestCheckMiddleware::class); $csrfFiltering = $this->container->get(CsrfResponseFilterMiddleware::class); $app->use($csrfChecking); $app->use($csrfFiltering); // ... $response = $csrfCheckMiddleware->process($request, $nextHandler); // ... $preparedResponse = $middleWare->process($request, $routingHandler);