8000 Merge branch '4.4' into 5.1 · symfony/symfony-docs@f7176f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7176f1

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [testing] document improving test speed by reducing encoder work factor
2 parents 23ff2e6 + eadb272 commit f7176f1

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

reference/configuration/security.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

testing/http_authentication.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@ How to Simulate HTTP Authentication in a Functional Test
1010
ease testing secured applications. See :ref:`testing_logging_in_users`
1111
for more information about this.
1212

13-
If you are still using an older version of Symfony, view
14-
`previous versions of this article`_ for information on how to simulate
15-
HTTP authentication.
16-
1713
.. _previous versions of this article: https://symfony.com/doc/5.0/testing/http_authentication.html

0 commit comments

Comments
 (0)
0