1414/**
1515 * For users that can be authenticated using a password.
1616 *
17+ * The __serialize/__unserialize() magic methods can be implemented on the user
18+ * class to prevent hashed passwords from being put in the session storage.
19+ * If the password is not stored at all in the session, getPassword() should
20+ * return null after unserialization, and then, changing the user's password
21+ * won't invalidate its sessions.
22+ * In order to invalidate the user sessions while not storing the password hash
23+ * in the session, it's also possible to hash the password hash before
24+ * serializing it; crc32c is the only algorithm supported.
25+ * For example:
26+ *
27+ * public function __serialize(): array
28+ * {
29+ * $data = (array) $this;
30+ * $data["\0".self::class."\0password"] = hash('crc32c', $this->password);
31+ *
32+ * return $data;
33+ * }
34+ *
35+ * Implement EquatableInteface if you need another logic.
36+ *
1737 * @author Robin Chalas <robin.chalas@gmail.com>
1838 * @author Wouter de Jong <wouter@wouterj.nl>
1939 */
@@ -23,9 +43,6 @@ interface PasswordAuthenticatedUserInterface
2343 * Returns the hashed password used to authenticate the user.
2444 *
2545 * Usually on authentication, a plain-text password will be compared to this value.
26- *
27- * The __serialize/__unserialize() magic methods can be implemented on the user
28- * class to prevent hashed passwords from being put in the session storage.
2946 */
3047 public function getPassword (): ?string ;
3148}
0 commit comments