Skip to content
Open
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
12 changes: 6 additions & 6 deletions src/services/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getMinimumPasswordLength(): int
* validation fails.
* @return string The hash.
*/
public function hashPassword(string $password, bool $validateHash = false): string
public function hashPassword(#[\SensitiveParameter] string $password, bool $validateHash = false): string
{
$hash = $this->generatePasswordHash($password, $this->_blowFishHashCost);

Expand All @@ -93,7 +93,7 @@ public function hashPassword(string $password, bool $validateHash = false): stri
* @see hkdf()
* @see pbkdf2()
*/
public function hashData($data, $key = null, $rawHash = false): string
public function hashData(#[\SensitiveParameter] $data, #[\SensitiveParameter] $key = null, $rawHash = false): string
{
if ($key === null) {
$key = Craft::$app->getConfig()->getGeneral()->securityKey;
Expand All @@ -118,7 +118,7 @@ public function hashData($data, $key = null, $rawHash = false): string
* @throws InvalidConfigException when HMAC generation fails.
* @see hashData()
*/
public function validateData($data, $key = null, $rawHash = false): string|false
public function validateData($data, #[\SensitiveParameter] $key = null, $rawHash = false): string|false
{
if ($key === null) {
$key = Craft::$app->getConfig()->getGeneral()->securityKey;
Expand All @@ -138,7 +138,7 @@ public function validateData($data, $key = null, $rawHash = false): string|false
* @see decryptByKey()
* @see encryptByPassword()
*/
public function encryptByKey($data, $inputKey = null, $info = null): string
public function encryptByKey(#[\SensitiveParameter] $data, #[\SensitiveParameter] $inputKey = null, $info = null): string
{
if ($inputKey === null) {
$inputKey = Craft::$app->getConfig()->getGeneral()->securityKey;
Expand All @@ -157,7 +157,7 @@ public function encryptByKey($data, $inputKey = null, $info = null): string
* @throws Exception on OpenSSL error
* @see encryptByKey()
*/
public function decryptByKey($data, $inputKey = null, $info = null): string|false
public function decryptByKey($data, #[\SensitiveParameter] $inputKey = null, $info = null): string|false
{
if ($inputKey === null) {
$inputKey = Craft::$app->getConfig()->getGeneral()->securityKey;
Expand Down Expand Up @@ -185,7 +185,7 @@ public function isSensitive(string $key): bool
* @param mixed $value
* @return mixed The possibly-redacted value
*/
public function redactIfSensitive(string $key, mixed $value): mixed
public function redactIfSensitive(string $key, #[\SensitiveParameter] mixed $value): mixed
{
if (is_array($value)) {
foreach ($value as $n => &$v) {
Expand Down