@@ -2779,22 +2779,21 @@ object) are "compared" to see if they are "equal". By default, the core
27792779your user will be logged out. This is a security measure to make sure that malicious
27802780users can be de-authenticated if core user data changes.
27812781
2782- Note that storing the (plain or hashed) password in the session storage can be seen
2783- as a security risk. In order to address this risk, the ``__serialize() `` magic method
2784- can be implemented on the user class to filter out the password before storing the
2785- serialized user object in the session.
2786- Two strategies are supported while serializing:
2787-
2788- #. Removing the password entirely. In this case, ``getPassword() `` will return ``null ``
2789- after unserialization and Symfony will refresh the user without checking the
2790- password. Use this strategy if you store plaintext passwords (not recommended.)
2791- #. Hashing the password using the ``crc32c `` algorithm. In this case Symfony will
2792- compare the password of the refreshed user after crc32c-hashing it. This is a good
2793- strategy if you use hashed passwords since it allows invalidating concurrent
2794- sessions when a password changes without storing the password hash in the session.
2795-
2796- Here is an example of how to implement this, assuming the password is found in a
2797- private property named ``password ``::
2782+ Storing the (plain or hashed) password in the session can be a security risk.
2783+ To mitigate this, implement the ``__serialize() `` magic method in your user class
2784+ to exclude or transform the password before storing the serialized user object
2785+ in the session.
2786+
2787+ Two strategies are supported:
2788+
2789+ #. Remove the password completely. After unserialization, ``getPassword() `` returns
2790+ ``null `` and Symfony refreshes the user without checking the password. Use this
2791+ only if you store plaintext passwords (not recommended).
2792+ #. Hash the password using the ``crc32c `` algorithm. Symfony will hash the password
2793+ of the refreshed user and compare it to the session value. This approach avoids
2794+ storing the real hash and lets you invalidate sessions on password change.
2795+
2796+ Example (assuming the password is stored in a private property called ``password ``)::
27982797
27992798 public function __serialize(): array
28002799 {
@@ -2804,6 +2803,11 @@ Two strategies are supported while serializing:
28042803 return $data;
28052804 }
28062805
2806+ .. versionadded :: 7.3
2807+
2808+ Support for hashing passwords with ``crc32c `` in session serialization was
2809+ introduced in Symfony 7.3.
2810+
28072811If you're having problems authenticating, it could be that you *are * authenticating
28082812successfully, but you immediately lose authentication after the first redirect.
28092813
0 commit comments