diff --git a/guides/security/users.rst b/guides/security/users.rst
index b0aab6efc68..0cc10c75f69 100644
--- a/guides/security/users.rst
+++ b/guides/security/users.rst
@@ -75,7 +75,7 @@ Encoding Passwords
~~~~~~~~~~~~~~~~~~
Instead of storing passwords in clear, you can encode them. When doing so, you
-should use a
+should retrieve a
:class:`Symfony\\Component\\Security\\Encoder\\PasswordEncoderInterface`
object::
@@ -91,12 +91,14 @@ object::
to check the user password; read the next section to learn how to make
your authentication provider aware of the encoder to use.
-For most use case, use
-:class:`Symfony\\Component\\Security\\Encoder\\MessageDigestPasswordEncoder`::
+If you need to encode passwords in your application code, for example when the
+user is signing up, or changing his password, you can retrieve the encoder from
+the :class:`Symfony\\Component\\Security\\Encoder\\EncoderFactoryInterface`::
+ $factory = $this->container->get('security.encoder_factory');
$user = new User();
- $encoder = new MessageDigestPasswordEncoder('sha1');
+ $encoder = $factory->getEncoder($user);
$password = $encoder->encodePassword('MyPass', $user->getSalt());
$user->setPassword($password);
@@ -104,6 +106,79 @@ When encoding your passwords, it's better to also define a unique salt per user
(the ``getSalt()`` method can return the primary key if users are persisted in
a database for instance).
+.. index::
+ single: Security; Configuring Encoders
+
+Configuring Encoders
+~~~~~~~~~~~~~~~~~~~~
+
+In this section, we will look at how you can set-up different encoders for your
+users. An encoder can either be one of the built-in encoders (
+:class:`Symfony\\Component\\Security\\Encoder\\PlaintextPasswordEncoder`, or
+:class:`Symfony\\Component\\Security\\Encoder\\MessageDigestPasswordEncoder`),
+or even a custom service. The following lists all available configuration
+options, you only need to select the one which suits your needs best::
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ # app/config/security.yml
+ security.config:
+ encoders:
+ MyBundle/Entity/MyUser: sha512
+ MyBundle/Entity/MyUser: plaintext
+ MyBundle/Entity/MyUser:
+ algorithm: sha512
+ encode-as-base64: true
+ iterations: 5
+ MyBundle/Entity/MyUser:
+ service: my.custom.encoder.service.id
+
+ .. code-block:: xml
+
+
+
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: