generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from keepsuit/track-headers
Track http headers
- Loading branch information
Showing
11 changed files
with
389 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Keepsuit\LaravelOpenTelemetry\Instrumentation; | ||
|
||
use Illuminate\Support\Arr; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait HandlesHttpHeaders | ||
{ | ||
/** | ||
* @var array<string> | ||
*/ | ||
protected array $defaultSensitiveHeaders = [ | ||
'authorization', | ||
'php-auth-pw', | ||
'cookie', | ||
'set-cookie', | ||
]; | ||
|
||
/** | ||
* @var array<string> | ||
*/ | ||
protected static array $allowedHeaders = []; | ||
|
||
/** | ||
* @var array<string> | ||
*/ | ||
protected static array $sensitiveHeaders = []; | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
public static function getAllowedHeaders(): array | ||
{ | ||
return static::$allowedHeaders; | ||
} | ||
|
||
public static function headerIsAllowed(string $header): bool | ||
{ | ||
return in_array($header, static::getAllowedHeaders()); | ||
} | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
public static function getSensitiveHeaders(): array | ||
{ | ||
return static::$sensitiveHeaders; | ||
} | ||
|
||
public static function headerIsSensitive(string $header): bool | ||
{ | ||
return in_array($header, static::getSensitiveHeaders()); | ||
} | ||
|
||
/** | ||
* @param array<string> $headers | ||
* @return array<string> | ||
*/ | ||
protected function normalizeHeaders(array $headers): array | ||
{ | ||
return Arr::map( | ||
$headers, | ||
fn (string $header) => strtolower(trim($header)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.