Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ApiKeyCredential | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of php-fast-forward/http-message. |
| 7 | * |
| 8 | * This source file is subject to the license bundled |
| 9 | * with this source code in the file LICENSE. |
| 10 | * |
| 11 | * @link https://github.com/php-fast-forward/http-message |
| 12 | * @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 13 | * @license https://opensource.org/licenses/MIT MIT License |
| 14 | */ |
| 15 | |
| 16 | namespace FastForward\Http\Message\Header\Authorization; |
| 17 | |
| 18 | /** |
| 19 | * Class ApiKeyCredential. |
| 20 | * |
| 21 | * Represents the credential structure for API Key–based authentication. |
| 22 | * Implementations using this credential MUST treat the API key as an opaque |
| 23 | * secret. The value MUST NOT be logged, exposed, or transmitted to |
| 24 | * unauthorized parties, as possession of the key typically grants full |
| 25 | * authorization to the associated account or resource. |
| 26 | * |
| 27 | * This class SHALL be returned by the {@see Authorization::ApiKey} parser |
| 28 | * when the `Authorization` header contains a valid API key value. The key |
| 29 | * MAY represent either a static key, a signed token, or any user-defined |
| 30 | * string depending on the server's authentication strategy. |
| 31 | */ |
| 32 | final class ApiKeyCredential implements AuthorizationCredential |
| 33 | { |
| 34 | /** |
| 35 | * Creates a new API Key credential instance. |
| 36 | * |
| 37 | * The provided key MUST be stored exactly as received and MUST NOT be |
| 38 | * modified or normalized internally. Any validation, expiration checks, |
| 39 | * or transformation logic MUST be performed by the caller or the |
| 40 | * authentication subsystem responsible for interpreting API keys. |
| 41 | * |
| 42 | * @param string $key the raw API key provided by the client |
| 43 | */ |
| 44 | public function __construct( |
| 45 | #[\SensitiveParameter] |
| 46 | public readonly string $key, |
| 47 | ) {} |
| 48 | } |