-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
tweaking the password upgrading functionality #12960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,21 +9,20 @@ How to Migrate a Password Hash | |||||
Password migration was introduced in Symfony 4.4. | ||||||
|
||||||
In order to protect passwords, it is recommended to store them using the latest | ||||||
hash algorithms. This means that if a better hash algorithm is supported on the | ||||||
system, the user's password should be rehashed and stored. Symfony provides this | ||||||
functionality when a user is successfully authenticated. | ||||||
|
||||||
To enable this, make sure you apply the following steps to your application: | ||||||
hash algorithms. This means that if a better hash algorithm is supported on your | ||||||
system, the user's password should be *rehashed* using the newer algorithm and | ||||||
stored. That's possible with the ``migrate_from`` option: | ||||||
|
||||||
#. `Configure a new Encoder Using "migrate_from"`_ | ||||||
#. `Upgrade the Password`_ | ||||||
#. Optionally, `Trigger Password Migration From a Custom Encoder`_ | ||||||
|
||||||
Configure a new Encoder Using "migrate_from" | ||||||
-------------------------------------------- | ||||||
---------------------------------------------- | ||||||
|
||||||
When configuring a new encoder, you can specify a list of legacy encoders by | ||||||
using the ``migrate_from`` option: | ||||||
When a better hashing algorithm becomes available, you should keep the existing | ||||||
encoder(s), rename it, and then define the new one. Set the ``migrate_from`` option | ||||||
on the new encoder to point to the old, legacy encoder(s): | ||||||
|
||||||
.. configuration-block:: | ||||||
|
||||||
|
@@ -34,6 +33,7 @@ using the ``migrate_from`` option: | |||||
# ... | ||||||
|
||||||
encoders: | ||||||
# an encoder used in the past for some users | ||||||
legacy: | ||||||
algorithm: sha256 | ||||||
encode_as_base64: false | ||||||
|
@@ -102,6 +102,13 @@ using the ``migrate_from`` option: | |||||
], | ||||||
]); | ||||||
|
||||||
With this setup: | ||||||
|
||||||
* New users will be encoded with the new algorithm; | ||||||
* Whenever a user logs in whose password is still stored using the old algorithm, | ||||||
Symfony will verify the password with the old algorithm and then re-encode | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Confusing Symfony terminology, but the password encoders are doing hashing. This is also consistent with earlier uses of "rehash(ing)" in the beginning of this chapter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made this change while merging. |
||||||
and update the hashed password using the new algorithm. | ||||||
|
||||||
.. tip:: | ||||||
|
||||||
The *auto*, *native*, *bcrypt* and *argon* encoders automatically enable | ||||||
|
@@ -110,7 +117,7 @@ using the ``migrate_from`` option: | |||||
#. :ref:`PBKDF2 <reference-security-pbkdf2>` (which uses :phpfunction:`hash_pbkdf2`); | ||||||
#. Message digest (which uses :phpfunction:`hash`) | ||||||
|
||||||
Both use the ``hash_algorithm`` setting as algorithm. It is recommended to | ||||||
Both use the ``hash_algorithm`` setting as the algorithm. It is recommended to | ||||||
use ``migrate_from`` instead of ``hash_algorithm``, unless the *auto* | ||||||
encoder is used. | ||||||
|
||||||
|
Uh oh!
There was an error while loading. Please reload this page.