Skip to content

Commit

Permalink
Warn if CsrfComponent is used together with CsrfProtectionMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
garas committed Sep 16, 2018
1 parent bb9b3db commit 8d44d24
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Controller/Component/CsrfComponent.php
Expand Up @@ -61,6 +61,19 @@ class CsrfComponent extends Component
'field' => '_csrfToken',
];

/**
* Warn if CsrfComponent is used together with CsrfProtectionMiddleware
*
* @param array $config The config data.
* @return void
*/
public function initialize(array $config)
{
if ($this->getController()->request->getParam('_csrfToken') !== false) {
triggerWarning('CSRF token already defined. Disable CsrfComponent if you use CsrfProtectionMiddleware.');
}
}

/**
* Startup callback.
*
Expand Down

0 comments on commit 8d44d24

Please sign in to comment.