@@ -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
1010Usually, the same password encoder is used for all users by configuring it
1111to 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
4250you want to use dynamically.
4351
4452In 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