Skip to content

[security-bundle recipe] Use less resource-intensive password hasher for test environment #1024

Closed
@maks-rafalko

Description

@maks-rafalko

As explained in different blog posts (here, here), and also in the docs - default password hasher (auto) consumes a lot of resources and takes too much time, especially when it's executed thousands of times in functional tests.

From https://symfony.com/doc/current/security/passwords.html#configuring-a-password-hasher

Hashing passwords is resource intensive and takes time in order to generate secure password hashes. In general, this makes your password hashing more secure.

In tests however, secure hashes are not important, so you can change the password hasher configuration in test environment to run tests faster:

# config/packages/test/security.yaml
password_hashers:
    # Use your user class name here
    App\Entity\User:
        algorithm: plaintext

So, what do you think to update an official recipe and in addition to config/packages/security.yaml add one more file - config/packages/test/security.yaml with the code above?

This will help many developers creating new projects to not waste time with functional tests.

Related to

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions