@@ -254,6 +254,68 @@ encoding algorithm. Also, each algorithm defines different config options:
254254 select a different password encoder for each user instance. Read
255255 :doc: `this article </security/named_encoders >` for more details.
256256
257+ .. tip ::
258+
259+ Encoding passwords is resource intensive and takes time in order to generate
260+ secure password hashes. In tests however, secure hashes are not important, so
261+ you can change the encoders configuration in ``test `` environment to run tests faster:
262+
263+ .. configuration-block ::
264+
265+ .. code-block :: yaml
266+
267+ # config/packages/test/security.yaml
268+ encoders :
269+ # Use your user class name here
270+ App\Entity\User :
271+ algorithm : auto # This should be the same value as in config/packages/security.yaml
272+ cost : 4 # Lowest possible value for bcrypt
273+ time_cost : 3 # Lowest possible value for argon
274+ memory_cost : 10 # Lowest possible value for argon
275+
276+ .. code-block :: xml
277+
278+ <!-- config/packages/test/security.xml -->
279+ <?xml version =" 1.0" encoding =" UTF-8" ?>
280+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
281+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
282+ xmlns : srv =" http://symfony.com/schema/dic/services"
283+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
284+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
285+
286+ <config >
287+ <!-- class: Use your user class name here -->
288+ <!-- algorithm: This should be the same value as in config/packages/security.yaml -->
289+ <!-- cost: Lowest possible value for bcrypt -->
290+ <!-- time_cost: Lowest possible value for argon -->
291+ <!-- memory_cost: Lowest possible value for argon -->
292+ <encoder
293+ class =" App\Entity\User"
294+ algorithm =" auto"
295+ cost =" 4"
296+ time_cost =" 3"
297+ memory_cost =" 10"
298+ />
299+ </config >
300+ </srv : container >
301+
302+ .. code-block :: php
303+
304+ // config/packages/test/security.php
305+ use App\Entity\User;
306+
307+ $container->loadFromExtension('security', [
308+ 'encoders' => [
309+ // Use your user class name here
310+ User::class => [
311+ 'algorithm' => 'auto', // This should be the same value as in config/packages/security.yaml
312+ 'cost' => 4, // Lowest possible value for bcrypt
313+ 'time_cost' => 3, // Lowest possible value for argon
314+ 'memory_cost' => 10, // Lowest possible value for argon
315+ ]
316+ ],
317+ ]);
318+
257319 .. _reference-security-sodium :
258320.. _using-the-argon2i-password-encoder :
259321
0 commit comments