-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added the way to activate remember me in the new authentication system #15464
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
Conversation
I had to search a while for myself not understanding why I did not have a REMEMBERME cookie when I activated the new system. So maybe handy to add it.
@@ -167,6 +167,27 @@ this: | |||
The user will then automatically be logged in on subsequent visits while | |||
the cookie remains valid. | |||
|
|||
Beware that in the new Authenitaction System you have to set the RememberMeBadge() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that in the new Authenitaction System you have to set the RememberMeBadge() | |
Beware that in the new authenitaction system you have to set the ``RememberMeBadge()`` |
@@ -167,6 +167,27 @@ this: | |||
The user will then automatically be logged in on subsequent visits while | |||
the cookie remains valid. | |||
|
|||
Beware that in the new Authenitaction System you have to set the RememberMeBadge() | |||
in the authenticate method of the authenticator, like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the authenticate method of the authenticator, like: | |
in the ``authenticate()`` method of the authenticator:: |
.. code-block:: php | ||
|
||
public function authenticate(Request $request): PassportInterface | ||
{ | ||
$email = $request->request->get('email', ''); | ||
|
||
$request->getSession()->set(Security::LAST_USERNAME, $email); | ||
|
||
return new Passport( | ||
new UserBadge($email), | ||
new PasswordCredentials($request->request->get('password', '')), | ||
[ | ||
new CsrfTokenBadge('authenticate', $request->get('_csrf_token')), | ||
new RememberMeBadge(), | ||
] | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. code-block:: php | |
public function authenticate(Request $request): PassportInterface | |
{ | |
$email = $request->request->get('email', ''); | |
$request->getSession()->set(Security::LAST_USERNAME, $email); | |
return new Passport( | |
new UserBadge($email), | |
new PasswordCredentials($request->request->get('password', '')), | |
[ | |
new CsrfTokenBadge('authenticate', $request->get('_csrf_token')), | |
new RememberMeBadge(), | |
] | |
); | |
} | |
public function authenticate(Request $request): PassportInterface | |
{ | |
$email = $request->request->get('email', ''); | |
$request->getSession()->set(Security::LAST_USERNAME, $email); | |
return new Passport( | |
new UserBadge($email), | |
new PasswordCredentials($request->request->get('password', '')), | |
[ | |
new CsrfTokenBadge('authenticate', $request->get('_csrf_token')), | |
new RememberMeBadge(), | |
] | |
); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
@@ -167,6 +167,27 @@ this: | |||
The user will then automatically be logged in on subsequent visits while | |||
the cookie remains valid. | |||
|
|||
Beware that in the new Authenitaction System you have to set the RememberMeBadge() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little spelling error :)
Beware that in the new Authenitaction System you have to set the RememberMeBadge() | |
Beware that in the new authentication system you have to set the ``RememberMeBadge()`` |
Hi there! There has been some unfortunate delay with documenting the new remember me system. I've proposed a complete update of the remember docs now: #16376 I've cherry-picked your commit in that PR, as it's just me being late on this PR that avoided this commit to make it into the docs repo in the first place. |
…dojulien, parijke, wouterj) This PR was merged into the 5.3 branch. Discussion ---------- [Security] Document the new remember me system Fixes #15721, fixes #16149 Replaces #15464, replaces #15893 Ref #15908 In Symfony 5.3, along with the new authentication system, we also somewhat silently introduced a new remember me system. Time to update the remember me docs with all new features :) This PR also includes 2 commits from open PRs in this repository. We've been very late with this one, and community members have already invested time in contributing necessary changes to the docs before. They deserve the credits :) `@javiereguiluz` I'm sorry for not informing you of this work before, I see you just merged a third PR that is replaced by this one. Commits ------- 5ac2d26 Document the new remember me system 2df2275 Added the way to activate remember me in the new authentication system d36b949 Update remember_me.rst
I had to search a while for myself not understanding why I did not have a REMEMBERME cookie when I activated the new system. So maybe handy to add it.