Skip to content

Commit 34e69de

Browse files
committed
[#3533] Lots of nice changes thanks to @xabbuh
1 parent 2fbf17c commit 34e69de

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

cookbook/security/named_encoders.rst

+22-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ How to Choose the Password Encoder Algorithm Dynamically
55
========================================================
66

77
.. versionadded:: 2.5
8-
Named encoders were introduced in Symfony 2.5
8+
Named encoders were introduced in Symfony 2.5.
99

1010
Usually, the same password encoder is used for all users by configuring it
1111
to apply to all instances of a specific class:
@@ -19,12 +19,20 @@ to apply to all instances of a specific class:
1919
.. code-block:: xml
2020
2121
<!-- app/config/security.xml -->
22-
<config>
23-
<!-- ... -->
24-
<encoder class="Symfony\Component\Security\Core\User\User"
25-
algorithm="sha512"
26-
/>
27-
</config>
22+
<?xml version="1.0" encoding="UTF-8"?>
23+
<srv:container xmlns="http://symfony.com/schema/dic/security"
24+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25+
xmlns:srv="http://symfony.com/schema/dic/services"
26+
xsi:schemaLocation="http://symfony.com/schema/dic/services
27+
http://symfony.com/schema/dic/services/services-1.0.xsd"
28+
>
29+
<config>
30+
<!-- ... -->
31+
<encoder class="Symfony\Component\Security\Core\User\User"
32+
algorithm="sha512"
33+
/>
34+
</config>
35+
</srv:container>
2836
2937
.. code-block:: php
3038
@@ -33,12 +41,12 @@ to apply to all instances of a specific class:
3341
// ...
3442
'encoders' => array(
3543
'Symfony\Component\Security\Core\User\User' => array(
36-
'algorithm' => 'sha512',
44+
'algorithm' => 'sha512',
3745
),
3846
),
3947
));
4048
41-
Another option is to use a "named" encoder, and then select which encoder
49+
Another option is to use a "named" encoder and then select which encoder
4250
you want to use dynamically.
4351

4452
In the previous example, you've set the ``sha512`` algorithm for ``Acme\UserBundle\Entity\User``.
@@ -63,7 +71,11 @@ named encoders:
6371
<!-- app/config/security.xml -->
6472
<?xml version="1.0" encoding="UTF-8" ?>
6573
<srv:container xmlns="http://symfony.com/schema/dic/security"
66-
xmlns:srv="http://symfony.com/schema/dic/services">
74+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
75+
xmlns:srv="http://symfony.com/schema/dic/services"
76+
xsi:schemaLocation="http://symfony.com/schema/dic/services
77+
http://symfony.com/schema/dic/services/services-1.0.xsd"
78+
>
6779
6880
<config>
6981
<!-- ... -->

0 commit comments

Comments
 (0)