Skip to content

Commit 5217466

Browse files
committed
minor #11446 Updated Argon2i encoder by Sodium encoder (javiereguiluz)
This PR was squashed before being merged into the master branch (closes #11446). Discussion ---------- Updated Argon2i encoder by Sodium encoder Fixes #11368. Commits ------- 8d9d7b5 Updated Argon2i encoder by Sodium encoder
2 parents 6c77530 + 8d9d7b5 commit 5217466

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

best_practices/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ remain resistant to brute-force search attacks.
3939

4040
.. note::
4141

42-
:ref:`Argon2i <reference-security-argon2i>` is the hashing algorithm as
42+
:ref:`Sodium <reference-security-sodium>` is the hashing algorithm as
4343
recommended by industry standards, but this won't be available to you unless
4444
you are using PHP 7.2+ or have the `libsodium`_ extension installed.
4545
``bcrypt`` is sufficient for most applications.

reference/configuration/security.rst

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ encoding algorithm. Also, each algorithm defines different config options:
137137
algorithm: 'bcrypt'
138138
cost: 15
139139
140-
# Argon2i encoder with default options
141-
App\Entity\User: 'argon2i'
140+
# Sodium encoder with default options
141+
App\Entity\User: 'sodium'
142142
143-
# Argon2i encoder with custom options
143+
# Sodium encoder with custom options
144144
App\Entity\User:
145-
algorithm: 'argon2i'
145+
algorithm: 'sodium'
146146
memory_cost: 16384 # Amount in KiB. (16384 = 16 MiB)
147147
time_cost: 2 # Number of iterations
148148
threads: 4 # Number of parallel threads
@@ -175,19 +175,19 @@ encoding algorithm. Also, each algorithm defines different config options:
175175
cost="15"
176176
/>
177177
178-
<!-- Argon2i encoder with default options -->
178+
<!-- Sodium encoder with default options -->
179179
<encoder
180180
class="App\Entity\User"
181-
algorithm="argon2i"
181+
algorithm="sodium"
182182
/>
183183
184-
<!-- Argon2i encoder with custom options -->
184+
<!-- Sodium encoder with custom options -->
185185
<!-- memory_cost: amount in KiB. (16384 = 16 MiB)
186186
time_cost: number of iterations
187187
threads: number of parallel threads -->
188188
<encoder
189189
class="App\Entity\User"
190-
algorithm="argon2i"
190+
algorithm="sodium"
191191
memory_cost="16384"
192192
time_cost="2"
193193
threads="4"
@@ -220,14 +220,14 @@ encoding algorithm. Also, each algorithm defines different config options:
220220
'cost' => 15,
221221
],
222222
223-
// Argon2i encoder with default options
223+
// Sodium encoder with default options
224224
User::class => [
225-
'algorithm' => 'argon2i',
225+
'algorithm' => 'sodium',
226226
],
227227
228-
// Argon2i encoder with custom options
228+
// Sodium encoder with custom options
229229
User::class => [
230-
'algorithm' => 'argon2i',
230+
'algorithm' => 'sodium',
231231
'memory_cost' => 16384, // Amount in KiB. (16384 = 16 MiB)
232232
'time_cost' => 2, // Number of iterations
233233
'threads' => 4, // Number of parallel threads
@@ -240,16 +240,27 @@ encoding algorithm. Also, each algorithm defines different config options:
240240
],
241241
]);
242242
243+
.. versionadded:: 4.3
244+
245+
The ``sodium`` algorithm was introduced in Symfony 4.3. In previous Symfony
246+
versions it was called ``argon2i``.
247+
243248
.. tip::
244249

245250
You can also create your own password encoders as services and you can even
246251
select a different password encoder for each user instance. Read
247252
:doc:`this article </security/named_encoders>` for more details.
248253

249-
.. _reference-security-argon2i:
254+
.. _reference-security-sodium:
255+
.. _using-the-argon2i-password-encoder:
256+
257+
Using the Sodium Password Encoder
258+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259+
260+
.. versionadded:: 4.3
250261

251-
Using the Argon2i Password Encoder
252-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262+
The ``SodiumPasswordEncoder`` was introduced in Symfony 4.3. In previous
263+
Symfony versions it was called ``Argon2iPasswordEncoder``.
253264

254265
It uses the `Argon2 key derivation function`_ and it's the encoder recommended
255266
by Symfony. Argon2 support was introduced in PHP 7.2, but if you use an earlier
@@ -267,7 +278,7 @@ Using the BCrypt Password Encoder
267278
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268279

269280
It uses the `bcrypt password hashing function`_ and it's recommended to use it
270-
when it's not possible to use Argon2i. The encoded passwords are ``60``
281+
when it's not possible to use Sodium. The encoded passwords are ``60``
271282
characters long, so make sure to allocate enough space for them to be persisted.
272283
Also, passwords include the `cryptographic salt`_ inside them (it's generated
273284
automatically for each new password) so you don't have to deal with it.
@@ -294,7 +305,7 @@ Using the PBKDF2 Encoder
294305
~~~~~~~~~~~~~~~~~~~~~~~~
295306

296307
Using the `PBKDF2`_ encoder is no longer recommended since PHP added support for
297-
Argon2i and bcrypt. Legacy application still using it are encouraged to upgrade
308+
Sodium and bcrypt. Legacy application still using it are encouraged to upgrade
298309
to those newer encoding algorithms.
299310

300311
firewalls

security.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ command will pre-configure this for you:
124124
encoders:
125125
# use your user class name here
126126
App\Entity\User:
127-
# bcrypt or argon2i are recommended
128-
# argon2i is more secure, but requires PHP 7.2 or the Sodium extension
127+
# bcrypt or sodium are recommended
128+
# sodium is more secure, but requires PHP 7.2 or the Sodium extension
129129
algorithm: bcrypt
130130
cost: 12
131131

security/named_encoders.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ be done with named encoders:
109109

110110
If you are running PHP 7.2+ or have the `libsodium`_ extension installed,
111111
then the recommended hashing algorithm to use is
112-
:ref:`Argon2i <reference-security-argon2i>`.
112+
:ref:`Sodium <reference-security-sodium>`.
113113

114114
This creates an encoder named ``harsh``. In order for a ``User`` instance
115115
to use it, the class must implement

0 commit comments

Comments
 (0)