Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 4: problem trying to update login form authenticator generated by makerBundle, RuntimeException about csrfToken

I have a project that started some time ago with Symfony 4. And I had login files generated from the php bin/console make:authcommand. Today I saw that the file information have changed a bit in the newer document so I wanted to update mine. I ran the same command again, renamed the new controller and authentication file. But when I tried it out, I got this error:

Cannot autowire service "App\Security\LoginFormAuthenticator": argument "$csrfTokenManager" of method "__construct()" references interface "Symfony\Component\Security\Csrf\CsrfTokenManagerInterface" but no such service exists. Did you create a class that implements this interface?

What does it mean?

like image 312
reddy Avatar asked Oct 26 '25 09:10

reddy


1 Answers

I had the same issue. You must enable the csrf protection in config/packages/framework.yaml:

framework:
    secret: '%env(APP_SECRET)%'
    csrf_protection: false #change this to true
like image 75
Rawburner Avatar answered Oct 29 '25 06:10

Rawburner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!