Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
BearerCredential
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(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
16namespace FastForward\Http\Message\Header\Authorization;
17
18/**
19 * Class BearerCredential.
20 *
21 * Represents the parsed credential for HTTP Bearer Token Authentication.
22 * Bearer tokens MUST be treated as opaque secrets that grant access to the
23 * associated protected resource. Any party in possession of the token MAY
24 * use it, therefore implementations MUST ensure the token is never exposed
25 * in logs, stack traces, debug output, or error messages.
26 *
27 * This credential SHALL be produced by the Bearer authentication parser in
28 * {@see FastForward\Http\Message\Header\Authorization::parse()} when a valid
29 * Bearer token is provided by the client.
30 */
31final class BearerCredential implements AuthorizationCredential
32{
33    /**
34     * Creates a new Bearer token credential instance.
35     *
36     * The token parameter is marked with `#[\SensitiveParameter]` because it
37     * MUST be handled as a private security secret; leaking its value may
38     * allow unauthorized access to the protected system.
39     *
40     * @param string $token the opaque bearer token provided by the client
41     */
42    public function __construct(
43        #[\SensitiveParameter]
44        public readonly string $token,
45    ) {}
46}