Skip to content

Commit d792c49

Browse files
committed
[cookbook][security] Adding details on how the passwords are encoded multiple times and converted to base64 - per tip from @stof
1 parent 91c6267 commit d792c49

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

cookbook/security/custom_provider.rst

+18-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ The value here should correspond with however the passwords were originally
230230
encoded when creating your users (however those users were created). When
231231
a user submits her password, the password is appended to the salt value and
232232
then encoded using this algorithm before being compared to the hashed password
233-
returned by your ``getPassword()`` method.
233+
returned by your ``getPassword()`` method. Additionally, depending on your
234+
options, the password may be encoded multiple times and encoded to base64.
234235

235236
.. sidebar:: Specifics on how passwords are encoded
236237

@@ -246,4 +247,19 @@ returned by your ``getPassword()`` method.
246247
then you'll need to do a bit more work so that Symfony properly encodes
247248
the password. That is beyond the scope of this entry, but would include
248249
sub-classing ``MessageDigestPasswordEncoder`` and overriding the ``mergePasswordAndSalt``
249-
method.
250+
method.
251+
252+
Additionally, the hash, by default, is encoded multiple times and encoded
253+
to base64. For specific details, see `MessageDigestPasswordEncoder`_.
254+
To prevent this, configure it in ``security.yml``:
255+
256+
.. code-block:: yaml
257+
258+
security:
259+
encoders:
260+
Acme\WebserviceUserBundle\Security\User\WebserviceUser:
261+
algorithm: sha512
262+
encode_as_base64: false
263+
iterations: 1
264+
265+
.. _MessageDigestPasswordEncoder: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php

0 commit comments

Comments
 (0)