Controller annotation for auto validation CSRF-tokens
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Krtv/Bundle/CsrfValidatorBundle
tests
.gitignore
LICENSE
README.md
composer.json

README.md

Intro to KrtvCsrfValidatorBundle

  • PHP >=5.5
  • KrtvCsrfValidatorBundle's 0.4.x compatible with symfony (>=2.7 versions).
  • 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>