| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | /** |
| 6: | * This file is part of the Nexus MCP SDK package. |
| 7: | * |
| 8: | * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com> |
| 9: | * |
| 10: | * For the full copyright and license information, please view |
| 11: | * the LICENSE file that was distributed with this source code. |
| 12: | */ |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Auth; |
| 15: | |
| 16: | /** |
| 17: | * What a validated bearer token grants, as reported by the host's token validator. |
| 18: | * |
| 19: | * @see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-5.2 |
| 20: | */ |
| 21: | final readonly class VerifiedAccessToken |
| 22: | { |
| 23: | /** |
| 24: | * PSR-7 request attribute a validated token travels on, from the middleware that checked it to the |
| 25: | * transport that puts it on the receive context. |
| 26: | */ |
| 27: | public const string REQUEST_ATTRIBUTE = 'nexus.mcp.access_token'; |
| 28: | |
| 29: | /** |
| 30: | * @param list<string> $audience Resources the token was issued for, at least one of which must be this server |
| 31: | * @param list<non-empty-string> $scopes Scopes the token was granted |
| 32: | * @param null|string $subject Resource owner the token acts for, absent when the client acts for itself |
| 33: | * @param null|string $clientId OAuth client the token was issued to |
| 34: | * @param null|int $expiresAt Unix timestamp the token expires at |
| 35: | */ |
| 36: | public function __construct( |
| 37: | public array $audience, |
| 38: | public array $scopes = [], |
| 39: | public ?string $subject = null, |
| 40: | public ?string $clientId = null, |
| 41: | public ?int $expiresAt = null, |
| 42: | ) { |
| 43: | } |
| 44: | } |
| 45: |