symfony: Twig function csrf_token('authenticate') returns 'csrf_token'

Symfony version(s) affected

7.2.0

Description

I am building a login form according to instructions here https://symfony.com/doc/current/security.html#form-login

When I make the following code: <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">

The function csrf_token('authenticate') generates thes tring csrf_token instead of an actual token. Making my login not work.

By comparison, executing csrf_token('randomstring') does generate a valid token.

What is happening here?

How to reproduce

Seems to be as simple as doing csrf_token('authenticate') in Twig.

Possible Solution

No response

Additional Context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 27 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Oh, this might be something to add to the doc, right? PR welcome!

Definitely

Le sam. 7 déc. 2024 à 15:35, Thibault G. @.***> a écrit :

@nicolas-grekas https://github.com/nicolas-grekas also to the make:security:form-login command no ?

— Reply to this email directly, view it on GitHub https://github.com/symfony/symfony/issues/59111#issuecomment-2525190607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB3PWRKLDBBMOQIDF26O6T2EMBUZAVCNFSM6AAAAABTFHMZD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRVGE4TANRQG4 . You are receiving this because you were mentioned.Message ID: @.***>

@cavias I tried to reproduce it on a fresh 7.2 simple project with a protected page and login form and the login worked with the stateless csrf with string “csrf-token”