Skip to content

Commit c700405

Browse files
committed
Add #[\SensitiveParameter] to token and verifier
1 parent 661ba98 commit c700405

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/Argon2SplitTokenFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function generate(\DateTimeImmutable | \DateInterval $expiresAt = null):
4040
return $splitToken->expireAt($this->getExpirationTimestamp($expiresAt));
4141
}
4242

43-
public function fromString(string | HiddenString | \Stringable $token): SplitToken
43+
public function fromString(#[\SensitiveParameter] string | HiddenString | \Stringable $token): SplitToken
4444
{
4545
return Argon2SplitToken::fromString($token);
4646
}

src/SplitToken.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ abstract class SplitToken
9898
private ?string $verifierHash = null;
9999
private ?\DateTimeImmutable $expiresAt = null;
100100

101-
final private function __construct(HiddenString $token, string $selector, string $verifier)
101+
final private function __construct(HiddenString $token, string $selector, #[\SensitiveParameter] string $verifier)
102102
{
103103
$this->token = $token;
104104
$this->selector = $selector;
@@ -150,7 +150,7 @@ public function expireAt(\DateTimeImmutable $expiresAt = null): static
150150
*
151151
* Note: The provided $token is zeroed from memory when it's length is valid.
152152
*/
153-
final public static function fromString(string | HiddenString | \Stringable $token): static
153+
final public static function fromString(#[\SensitiveParameter] string | HiddenString | \Stringable $token): static
154154
{
155155
if ($token instanceof HiddenString) {
156156
$token = $token->getString();
@@ -259,5 +259,5 @@ protected function configureHasher(array $config): void
259259
abstract protected function verifyHash(string $hash, string $verifier): bool;
260260

261261
/** Produces a hashed version of the verifier. */
262-
abstract protected function hashVerifier(string $verifier): string;
262+
abstract protected function hashVerifier(#[\SensitiveParameter] string $verifier): string;
263263
}

src/SplitTokenFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ public function generate(\DateTimeImmutable | \DateInterval $expiresAt = null):
4646
* return SplitToken::fromString($token);
4747
* ```
4848
*/
49-
public function fromString(string | HiddenString | \Stringable $token): SplitToken;
49+
public function fromString(#[\SensitiveParameter] string | HiddenString | \Stringable $token): SplitToken;
5050
}

tests/FakeSplitTokenFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ public function it_creates_from_stringable_object(): void
118118
$splitToken = $factory->generate();
119119

120120
$stringObj = new class($splitToken->token()->getString()) implements \Stringable {
121-
public function __construct(private string $value) {}
121+
public function __construct(
122+
#[\SensitiveParameter]
123+
private string $value
124+
) {}
122125

123126
public function __toString(): string
124127
{

0 commit comments

Comments
 (0)