I created a website with a user login using Sulu CMF. For the user login, I would like to create a "remember me" checkbox. According to Symfony docs, all that need to be done is
- adjust firewall settings in
security.yaml - add a checkbox to the form, with
name="_remember_me" - add Remember Me Support to the Authenticator
The first two points are straight forward. For the third point, "add Remember Me Support to the Authenticator" I am a bit lost, as with sulu I am not using a custom authenticator, but Sulu rather provides the authentication mechanism, with Sulu users and roles an all that.
How can I tell the Sulu authenticator to add the RememberMeBadge to the authentication Passport as described in the docs?
Update: When loggin in, the server responds with the REMEMBERME cookie, but with the value "deleted".
Finally I got it working by creating a custom Authenticator. The reason why it did not work in the first place is due to the symfony
FormLoginAuthenticatorthat creates theRememberMeBadge, but does not enable it. See https://github.com/symfony/security-http/blob/7.0/Authenticator/FormLoginAuthenticator.phpHere you see that the RememberMeBadge is disabled by default: https://github.com/symfony/security-http/blob/7.0/Authenticator/Passport/Badge/RememberMeBadge.php
That fact that the badge is created but not enabled, does not make sense to me, maybe this is a bug in the Symfony framework.
However, a custom Authenticator that creates and enables the badge, solved the issue for me.
The authenticator was created using the symfony cli command
php bin/console make:authwith some minor adjustments.