I need to completely disable the control of the CSRF token for my application. I tried to use:
public function beforeFilter(Event $event)
{
$this->getEventManager()->off($this->Csrf);
}
In AppController but it does not seem to work. Manual link: Disabling the CSRF Component for Specific Actions
I did a lot of tests, read many posts but I could not solve.
Ty.
@omerowitz This is my AppController before filter action:
public function beforeFilter(Event $event)
{
$this->getEventManager()->off($this->Security);
if($this->request->is('post')) {
$this->getEventManager()->off($this->Csrf);
}
$this->Auth->allow(['index', 'view', 'display']);
}
but it still does not work, I still have the error 'CSRF token mismatch.' when I effect a request with postman
SOLUTION:
I have remove this :
->add(new CsrfProtectionMiddleware([
'httpOnly' => true
]));
From Application.php. Why this is not indicated in the manual?
Ty all!