I have a Symfony 5.4, in dev env (docker) the login works fine. But when I try the same login via docker on prod, i have :
{"message":"Invalid CSRF token."}
AppAuthenticator.php
public function authenticate(Request $request): Passport
{
.....
return new Passport(
new UserBadge($credentials['username']),
new PasswordCredentials($credentials['password']),
[new CsrfTokenBadge('authenticate', $credentials['csrf_token'])]
);
}
security.yaml
security:
firewalls:
main:
form_login:
login_path: _security_login
check_path: _security_check
enable_csrf: true
login.html.twig
<form method="post">
....
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
</form>