@@ -119,14 +119,43 @@ Upgrade the Password
119
119
120
120
Upon successful login, the Security system checks whether a better algorithm
121
121
is available to hash the user's password. If it is, it'll hash the correct
122
- password using the new hash. You can enable this behavior by implementing how
123
- this newly hashed password should be stored:
122
+ password using the new hash. If you use a Guard authenticator, you first need to
123
+ `provide the original password to the Security system <Provide the Password when using Guards >`_.
124
+
125
+ You can enable the upgrade behavior by implementing how this newly hashed
126
+ password should be stored:
124
127
125
128
* `When using Doctrine's entity user provider <Upgrade the Password when using Doctrine >`_
126
129
* `When using a custom user provider <Upgrade the Password when using a custom User Provider >`_
127
130
128
131
After this, you're done and passwords are always hashed as secure as possible!
129
132
133
+ Provide the Password when using Guards
134
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
+
136
+ When you're using a custom :doc: `guard authenticator </security/guard_authentication >`,
137
+ you need to implement :class: `Symfony\\ Component\\ Security\\ Guard\\ PasswordAuthenticatedInterface `.
138
+ This interfaces defines a ``getPassword() `` method that returns the password
139
+ for this login request. This password is used in the migration process.
140
+
141
+ .. code-block :: php
142
+
143
+ // src/Security/TokenAuthenticator.php
144
+ namespace App\Security;
145
+
146
+ use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface;
147
+ // ...
148
+
149
+ class CustomAuthenticator extends AbstractGuardAuthenticator implements PasswordAuthenticatedInterface
150
+ {
151
+ // ...
152
+
153
+ public function getPassword($credentials): ?string
154
+ {
155
+ return $credentials['password'];
156
+ }
157
+ }
158
+
130
159
Upgrade the Password when using Doctrine
131
160
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132
161
0 commit comments