Hello, How works CSRF protection in Slim v4?
You could also take a look at my Slim 4 CSRF package: https://github.com/odan/csrf
Update: Maybe you don’t need CSRF protection anymore: https://scotthelme.co.uk/csrf-is-really-dead/
Solution: use it without Middleware
Instead of using a separate middleware for CSRF Attack Protection, we should use it directly in our bootstrapper file like this
Now you can use these csrf fields in you template files like this
Ps: update this block as per your requirements or you can move these all to different file as well
Adding Twig v3 Globals for csrf fields will give you this error in Slim 4
Unable to add global “csrf” as the runtime or the extensions have already been initialized.
To fix these I implemented this answer.
Thanks & Regards