@@ -22,7 +22,7 @@ class RememberMeDetails
22
22
public const COOKIE_DELIMITER = ': ' ;
23
23
24
24
public function __construct (
25
- private string $ userFqcn ,
25
+ private string $ userFqcnHash ,
26
26
private string $ userIdentifier ,
27
27
private int $ expires ,
28
28
private string $ value ,
@@ -48,7 +48,12 @@ public static function fromRawCookie(string $rawCookie): self
48
48
49
49
public static function fromPersistentToken (PersistentToken $ persistentToken , int $ expires ): self
50
50
{
51
- return new static ($ persistentToken ->getClass (), $ persistentToken ->getUserIdentifier (), $ expires , $ persistentToken ->getSeries ().': ' .$ persistentToken ->getTokenValue ());
51
+ return new static (self ::computeUserFqcnHash ($ persistentToken ->getClass ()), $ persistentToken ->getUserIdentifier (), $ expires , $ persistentToken ->getSeries ().': ' .$ persistentToken ->getTokenValue ());
52
+ }
53
+
54
+ public static function computeUserFqcnHash (string $ userFqcn ): string
55
+ {
56
+ return hash ('sha256 ' , $ userFqcn );
52
57
}
53
58
54
59
public function withValue (string $ value ): self
@@ -59,9 +64,9 @@ public function withValue(string $value): self
59
64
return $ details ;
60
65
}
61
66
62
- public function getUserFqcn (): string
67
+ public function getUserFqcnHash (): string
63
68
{
64
- return $ this ->userFqcn ;
69
+ return $ this ->userFqcnHash ;
65
70
}
66
71
67
72
public function getUserIdentifier (): string
@@ -82,6 +87,6 @@ public function getValue(): string
82
87
public function toString (): string
83
88
{
84
89
// $userIdentifier is encoded because it might contain COOKIE_DELIMITER, we assume other values don't
85
- return implode (self ::COOKIE_DELIMITER , [strtr ( $ this ->userFqcn , '\\' , ' . ' ) , strtr (base64_encode ($ this ->userIdentifier ), '+/= ' , '-_~ ' ), $ this ->expires , $ this ->value ]);
90
+ return implode (self ::COOKIE_DELIMITER , [$ this ->userFqcnHash , strtr (base64_encode ($ this ->userIdentifier ), '+/= ' , '-_~ ' ), $ this ->expires , $ this ->value ]);
86
91
}
87
92
}
0 commit comments