Skip to content

[Security] Prevent unneeded implementation of PasswordHasherAwareInterface when migrating passwords #17641

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

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions security/passwords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Further in this article, you can find a
.. configuration-block::

.. code-block:: yaml

# config/packages/test/security.yaml
security:
# ...
Expand Down Expand Up @@ -544,8 +544,10 @@ migration by returning ``true`` in the ``needsRehash()`` method::
}
}

Named Password Hashers
----------------------
.. _named-password-hashers:

Dynamic Password Hashers
------------------------

Usually, the same password hasher is used for all users by configuring it
to apply to all instances of a specific class. Another option is to use a
Expand Down Expand Up @@ -646,6 +648,12 @@ the name of the hasher to use::
}
}

.. caution::

When :ref:`migrating passwords <security-password-migration>`, you don't need to implement ``PasswordHasherAwareInterface``
to return the legacy hasher name:
Symfony will detect it from your ``migrate_from`` configuration.

If you created your own password hasher implementing the
:class:`Symfony\\Component\\PasswordHasher\\PasswordHasherInterface`,
you must register a service for it in order to use it as a named hasher:
Expand Down