diff --git a/performance.rst b/performance.rst index afd5295a9e3..50aeca8632b 100644 --- a/performance.rst +++ b/performance.rst @@ -17,6 +17,7 @@ for maximum performance: * **Symfony Application Checklist**: #. :ref:`Install APCu Polyfill if your server uses APC ` + #. :ref:`Hash passwords faster only for tests ` * **Production Server Checklist**: @@ -37,6 +38,73 @@ OPcache, install the `APCu Polyfill component`_ in your application to enable compatibility with `APCu PHP functions`_ and unlock support for advanced Symfony features, such as the APCu Cache adapter. +.. _performance-hash-passwords-faster: + +Hash Passwords Faster Only for Tests +------------------------------------ + +By default, :ref:`password encoders ` are +resource intensive and take time. This is important to generate secure password +hashes. In tests however, secure hashes are not important, so you can make your +tests faster changing the encoders configuration to generate password hashes as +fast as possible: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/test/security.yaml + encoders: + # Use your user class name here + App\Entity\User: + algorithm: auto # This should be the same value as in config/packages/security.yaml + cost: 4 # Lowest possible value for bcrypt + time_cost: 3 # Lowest possible value for argon + memory_cost: 10 # Lowest possible value for argon + + .. code-block:: xml + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/test/security.php + use App\Entity\User; + + $container->loadFromExtension('security', [ + 'encoders' => [ + // Use your user class name here + User::class => [ + 'algorithm' => 'auto', // This should be the same value as in config/packages/security.yaml + 'cost' => 4, // Lowest possible value for bcrypt + 'time_cost' => 3, // Lowest possible value for argon + 'memory_cost' => 10, // Lowest possible value for argon + ] + ], + ]); + .. _performance-service-container-single-file: Dump the Service Container into a Single File diff --git a/testing/http_authentication.rst b/testing/http_authentication.rst index 336f6f12b39..9ab070fb181 100644 --- a/testing/http_authentication.rst +++ b/testing/http_authentication.rst @@ -12,70 +12,6 @@ OAuth authentication services. This article explains some of the most popular techniques to avoid these issues and create fast tests when using authentication. -Hashing Passwords Faster Only for Tests ---------------------------------------- - -By default, :ref:`password encoders ` are -resource intensive and take time. This is important to generate secure password -hashes. In tests however, secure hashes are not important, so you can change the -encoders configuration to generate password hashes as fast as possible: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/test/security.yaml - encoders: - # Use your user class name here - App\Entity\User: - algorithm: auto # This should be the same value as in config/packages/security.yaml - cost: 4 # Lowest possible value for bcrypt - time_cost: 3 # Lowest possible value for argon - memory_cost: 10 # Lowest possible value for argon - - .. code-block:: xml - - - - - - - - - - - - - - - - .. code-block:: php - - // config/packages/test/security.php - use App\Entity\User; - - $container->loadFromExtension('security', [ - 'encoders' => [ - // Use your user class name here - User::class => [ - 'algorithm' => 'auto', // This should be the same value as in config/packages/security.yaml - 'cost' => 4, // Lowest possible value for bcrypt - 'time_cost' => 3, // Lowest possible value for argon - 'memory_cost' => 10, // Lowest possible value for argon - ] - ], - ]); - Using a Faster Authentication Mechanism Only for Tests ------------------------------------------------------