Skip to content

Commit

Permalink
Mask authorization header
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Jun 24, 2024
1 parent edf5dde commit 811bdcd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Message/CommandHandler/ProcessUploadOrderRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,23 @@ private static function stringifyMessage(RequestInterface|ResponseInterface|null
);
}

// todo mask authorization header
/**
* @var string $name
* @var list<string> $values
*/
foreach ($message->getHeaders() as $name => $values) {
$result .= sprintf("%s: %s\n", $name, implode(', ', $values));
$value = implode(', ', $values);

if ('authorization' === strtolower($name) && strlen($value) > 8) {
$value = substr_replace(
$value,
str_repeat('*', strlen($value) - 8),
4,
-4,
);
}

$result .= sprintf("%s: %s\n", $name, $value);
}

$body = trim((string) $message->getBody());
Expand Down

0 comments on commit 811bdcd

Please sign in to comment.