csrf-validator-bundle
csrf-validator-bundle copied to clipboard
Controller annotation for auto validation CSRF-tokens
Intro to KrtvCsrfValidatorBundle
- PHP
>=5.5 - KrtvCsrfValidatorBundle's
0.4.xcompatible with symfony (>=2.7versions). - Doctrine is required
Features:
- Add extra annotation for auto validation CSRF-tokens to your controller actions
Installation and configuration:
Pretty simple with Composer, add:
{
"require": {
"korotovsky/csrf-validator-bundle": "0.4.*"
}
}
For latest version (UNSTABLE) use
{
"require": {
"korotovsky/csrf-validator-bundle": "~0.4.0@dev"
}
}
Configuration example
- No specific configuration is needed!
Add KrtvCsrfValidatorBundle to your application kernel
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Krtv\Bundle\CsrfValidatorBundle\KrtvCsrfValidatorBundle(),
// ...
);
}
Usage examples:
Just add annotation to your controller action
// Acme\MainBundle\Controller\DefaultController.php
use Krtv\Bundle\CsrfValidatorBundle\Annotations as Krtv;
/**
* @Krtv\Csrf(intention="your_intention")
* @return Response
*/
public function importantZoneAction()
{
// some code here ...
return new Response();
}
View
<a href="{{ path('_some_route', {'token': csrf_token('your_intention')}) }}">Subscribe!</a>