Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

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:

# config/packages/security.yaml
    # ...
-            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.


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.