Skip to content

Clarify & expand service decoration description #16161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions security/remember_me.rst
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,42 @@ service you created before:
->tokenProvider(DoctrineTokenProvider::class)
;
};

Activating Remember Me When Using a Custom Authenticator
--------------------------------------------------------

When you use a custom authenticator, you must add a ``RememberMeBadge`` to the ``Passport``
for the remember me function to be activated. Without the badge, remember me will not be
active, regardless of any other remember me settings.

For example::

// src/Service/LoginAuthenticator.php
namespace App\Service;

// ...
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;

class LoginAuthenticator extends AbstractAuthenticator
{
public function authenticate(Request $request): PassportInterface
{
$password = $request->request->get('password');
$username = $request->request->get('username');
$csrfToken = $request->request->get('csrf_token');

return new Passport(
new UserBadge($username),
new PasswordCredentials($password),
[
new CsrfTokenBadge('login', $csrfToken),
new RememberMeBadge(),
]
);
}
}
Loading