phpolar / csrf-protection
提供请求检查和响应过滤,以减轻CSRF攻击
3.1.0
2023-09-02 22:12 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: ^10.0
- 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保护
基于PSR-7和PSR-15的HTTP请求CSRF保护
目录
安装
composer require phpolar/csrf-protection
用法
$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);