{"action":"created","issue":{"url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/2","labels_url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/2/comments","events_url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/2/events","html_url":"https://github.com/dunglas/DunglasAngularCsrfBundle/issues/2","id":39172502,"number":2,"title":"Consider adding a Form Extension for disabling csrf when the class is used","user":{"login":"tarjei","id":211263,"avatar_url":"https://avatars.githubusercontent.com/u/211263?v=3","gravatar_id":"","url":"https://api.github.com/users/tarjei","html_url":"https://github.com/tarjei","followers_url":"https://api.github.com/users/tarjei/followers","following_url":"https://api.github.com/users/tarjei/following{/other_user}","gists_url":"https://api.github.com/users/tarjei/gists{/gist_id}","starred_url":"https://api.github.com/users/tarjei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarjei/subscriptions","organizations_url":"https://api.github.com/users/tarjei/orgs","repos_url":"https://api.github.com/users/tarjei/repos","events_url":"https://api.github.com/users/tarjei/events{/privacy}","received_events_url":"https://api.github.com/users/tarjei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/milestones/1","labels_url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/milestones/1/labels","id":900763,"number":1,"title":"v1.0.0","description":"","creator":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2014-12-11T17:45:16Z","updated_at":"2014-12-11T17:45:25Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2014-07-31T08:14:48Z","updated_at":"2015-01-14T16:24:37Z","closed_at":null,"body":"Something like this:\r\n\r\n```php\r\n/**\r\n * Class DisableCSRFExtension\r\n *\r\n * @author Grégoire Pineau\r\n * @author Tarjei Huse (Extended the class to disable csrf on forms)\r\n * \r\n */\r\nclass DisableCSRFExtension extends AbstractTypeExtension\r\n{\r\n    private $securityContext;\r\n    /**\r\n     * @var RequestStack\r\n     */\r\n    private $requestStack;\r\n    /**\r\n     * @var AngularCsrfTokenManager\r\n     */\r\n    private $angularCsrfTokenManager;\r\n    /**\r\n     * @var RouteMatcherInterface\r\n     */\r\n    private $routeMatcher;\r\n    /**\r\n     * @var array\r\n     */\r\n    private $routes;\r\n    /**\r\n     * @var\r\n     */\r\n    private $headerName;\r\n\r\n\r\n    /**\r\n     * @param SecurityContextInterface $securityContext\r\n     * @param RequestStack             $requestStack\r\n     * @param AngularCsrfTokenManager  $angularCsrfTokenManager\r\n     * @param RouteMatcherInterface    $routeMatcher\r\n     */\r\n    public function __construct(SecurityContextInterface $securityContext,\r\n                                RequestStack $requestStack,\r\n                                AngularCsrfTokenManager $angularCsrfTokenManager,\r\n                                RouteMatcherInterface $routeMatcher,\r\n                                array $routes,\r\n                                $headerName\r\n    )\r\n    {\r\n        $this->securityContext = $securityContext;\r\n        $this->requestStack = $requestStack;\r\n        $this->angularCsrfTokenManager = $angularCsrfTokenManager;\r\n        $this->routeMatcher = $routeMatcher;\r\n        $this->routes = $routes;\r\n        $this->headerName = $headerName;\r\n    }\r\n\r\n    public function setDefaultOptions(OptionsResolverInterface $resolver)\r\n    {\r\n        if (!$this->securityContext->getToken()) {\r\n            return;\r\n        }\r\n        $request = $this->requestStack->getCurrentRequest();\r\n        if (!$this->routeMatcher->match($request, $this->routes)\r\n        ) {\r\n            return;\r\n        }\r\n        $value = $request->headers->get($this->headerName);\r\n        \r\n        if ($this->angularCsrfTokenManager->isTokenValid($value)) {\r\n            $resolver->setDefaults(array(\r\n                'csrf_protection' => false,\r\n            ));\r\n        }\r\n    }\r\n\r\n    public function getExtendedType()\r\n    {\r\n        return 'form';\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/comments/69943224","html_url":"https://github.com/dunglas/DunglasAngularCsrfBundle/issues/2#issuecomment-69943224","issue_url":"https://api.github.com/repos/dunglas/DunglasAngularCsrfBundle/issues/2","id":69943224,"user":{"login":"xavierleune","id":2320425,"avatar_url":"https://avatars.githubusercontent.com/u/2320425?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierleune","html_url":"https://github.com/xavierleune","followers_url":"https://api.github.com/users/xavierleune/followers","following_url":"https://api.github.com/users/xavierleune/following{/other_user}","gists_url":"https://api.github.com/users/xavierleune/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierleune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierleune/subscriptions","organizations_url":"https://api.github.com/users/xavierleune/orgs","repos_url":"https://api.github.com/users/xavierleune/repos","events_url":"https://api.github.com/users/xavierleune/events{/privacy}","received_events_url":"https://api.github.com/users/xavierleune/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T16:24:37Z","updated_at":"2015-01-14T16:24:37Z","body":":+1:"}}