Skip to content

Add more #[\SensitiveParameter] #48274

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
Nov 22, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
* @param $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault
* or null to store generated keys in the provided $secretsDir
*/
public function __construct(string $secretsDir, string|\Stringable $decryptionKey = null)
public function __construct(string $secretsDir, #[\SensitiveParameter] string|\Stringable $decryptionKey = null)
{
$this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.';
$this->decryptionKey = $decryptionKey;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/Csrf/CsrfTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getToken(string $tokenId): CsrfToken
return new CsrfToken($tokenId, $this->randomize($value));
}

public function refreshToken(#[\SensitiveParameter] string $tokenId): CsrfToken
public function refreshToken(string $tokenId): CsrfToken
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GromNaN I think this one was a mistake. It was not added to the interface and all other CSRF token ids. WDYT?

{
$namespacedId = $this->getNamespace().$tokenId;
$value = $this->generator->generateToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getToken(string $tokenId): string
return (string) $_SESSION[$this->namespace][$tokenId];
}

public function setToken(string $tokenId, string $token)
public function setToken(string $tokenId, #[\SensitiveParameter] string $token)
{
if (!$this->sessionStarted) {
$this->startSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getToken(string $tokenId): string
return (string) $session->get($this->namespace.'/'.$tokenId);
}

public function setToken(string $tokenId, string $token)
public function setToken(string $tokenId, #[\SensitiveParameter] string $token)
{
$session = $this->getSession();
if (!$session->isStarted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getToken(string $tokenId): string;
/**
* Stores a CSRF token.
*/
public function setToken(string $tokenId, string $token);
public function setToken(string $tokenId, #[\SensitiveParameter] string $token);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #46183:

The attribute has no effect on the interface, but is a remainder for implementers.


/**
* Removes a CSRF token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ interface AccessTokenHandlerInterface
/**
* @throws AuthenticationException
*/
public function getUserIdentifierFrom(string $accessToken): string;
public function getUserIdentifierFrom(#[\SensitiveParameter] string $accessToken): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CsrfTokenBadge implements BadgeInterface
* Using a different string for each authenticator improves its security.
* @param string|null $csrfToken The CSRF token presented in the request, if any
*/
public function __construct(string $csrfTokenId, ?string $csrfToken)
public function __construct(string $csrfTokenId, #[\SensitiveParameter] ?string $csrfToken)
{
$this->csrfTokenId = $csrfTokenId;
$this->csrfToken = $csrfToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PasswordUpgradeBadge implements BadgeInterface
* @param string $plaintextPassword The presented password, used in the rehash
* @param PasswordUpgraderInterface|null $passwordUpgrader The password upgrader, defaults to the UserProvider if null
*/
public function __construct(string $plaintextPassword, PasswordUpgraderInterface $passwordUpgrader = null)
public function __construct(#[\SensitiveParameter] string $plaintextPassword, PasswordUpgraderInterface $passwordUpgrader = null)
{
$this->plaintextPassword = $plaintextPassword;
$this->passwordUpgrader = $passwordUpgrader;
Expand Down