infuse / csrf
Anti-CSRF module for Infuse Framework
1.1
2017-12-16 16:12 UTC
Requires
- php: >=7.0.0
- symfony/security-csrf: ~2.8|~3.0|~4.0
Requires (Dev)
- infuse/infuse: ~1.6
- mockery/mockery: ~1.0
- phpunit/phpunit: 6.0.*
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2024-12-13 08:48:18 UTC
README
CSRF protection for Infuse Framework. Built on symfony/security-csrf.
Installation
-
Install the package with composer:
composer require infuse/csrf
-
Add the services in your app's configuration:
'services' => [ // ... 'csrf' => 'Infuse\Csrf\Csrf', 'csrf_tokens' => 'Infuse\Csrf\CsrfTokens', // ... ]
-
Add the middleware to your app:
$app->middleware($app['csrf']);
Usage
Any POST, PUT, PATCH, and DELETE request that has the middleware installed will check for a valid CSRF token. With a line of code you can add CSRF tokens to a form (Smarty example):
<form action="/transfer" method="POST"> {$app.csrf->render($req) nofilter} <!-- rest of your form... --> </form>