File tree Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -198,10 +198,36 @@ own, it just needs to follow these rules:
198
198
199
199
#. The class must implement :class: `Symfony\\ Component\\ Security\\ Core\\ Encoder\\ PasswordEncoderInterface `;
200
200
201
- #. The first line in ``encodePassword `` and ``isPasswordValid `` must check
202
- to make sure the password is not too long (e.g. 4096). This is for security
203
- (see `CVE-2013-5750 `_), and you can copy the `BasePasswordEncoder::checkPasswordLength `_
204
- implementation from Symfony 2.4.
201
+ #. The implementations of
202
+ :method: `Symfony\\ Component\\ Security\\ Core\\ Encoder\\ PasswordEncoderInterface::encodePassword `
203
+ and
204
+ :method: `Symfony\\ Component\\ Security\\ Core\\ Encoder\\ PasswordEncoderInterface::isPasswordValid `
205
+ must first of all make sure the password is not too long, i.e. the password length is no longer
206
+ than 4096 characters. This is for security reasons (see `CVE-2013-5750 `_), and you can use the
207
+ :method: `Symfony\\ Component\\ Security\\ Core\\ Encoder\\ BasePasswordEncoder::isPasswordTooLong`_
208
+ method for this check:
209
+
210
+ use Symfony\C omponent\S ecurity\C ore\E xception\B adCredentialsException;
211
+
212
+ class FoobarEncoder extends BasePasswordEncoder
213
+ {
214
+ public function encodePassword($raw, $salt)
215
+ {
216
+ if ($this->isPasswordTooLong($raw)) {
217
+ throw new BadCredentialsException('Invalid password.');
218
+ }
219
+
220
+ // ...
221
+ }
222
+
223
+ public function isPasswordValid($encoded, $raw, $salt)
224
+ {
225
+ if ($this->isPasswordTooLong($raw)) {
226
+ return false;
227
+ }
228
+
229
+ // ...
230
+ }
205
231
206
232
Using Password Encoders
207
233
~~~~~~~~~~~~~~~~~~~~~~~
You can’t perform that action at this time.
0 commit comments