English spoken conference

Symfony 5: The Fast Track

A new book to learn about developing modern Symfony 5 applications.

Support this project

New in Symfony 4.3: Sodium password encoder

Contributed by
Robin Chalas
in #31019.

In Symfony 3.4 we added an Argon2i password hasher as a modern replacement of the Bcrypt hasher. Argon2i support is provided through the libsodium library, which selects the Argon2 variant (argon2d, argon2i or argon2id) automatically based on the host system.

Given that the Argon2 variant selection is out of Symfony's control, in Symfony 4.3 we've decided to not add an Argon2idPasswordEncoder, to deprecate the Argon2iPasswordEncoder class and to add instead a generic SodiumPasswordEncoder class.

This new encoder relies on libsodium to select the best possible Argon2 variant. In practice, the only change you'll need to make in most of your applications is to update the name of the hashing algorithm in the main security config file:

1
2
3
4
5
6
7
# config/packages/security.yaml
security:
    # ...
    encoders:
        App\Entity\User:
-            algorithm: argon2i
+            algorithm: sodium

The name of the Argon2 variant used to hash the password is included in the hash itself, so you can update this config option safely. If a new variant is picked by libsodium, all your existing passwords will keep working.

Besides, all the existing Argon2i configuration options are still available under the new sodium algorithm name.

Comments

Thank you Robin 👍🏻
A good improvement. Thank you Robin.
fair enough!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.