Validates JWT tokens against security constraints for authentication.
// Source: https://github.com/lcobucci/jwt | License: BSD-3-Clause | Copyright 2014, Luís Cobucci
// Provided via justclaw.it.com; keep this notice with the code.
<?php
declare(strict_types=1);
namespace Lcobucci\JWT\Validation;
use Lcobucci\JWT\Token;
final readonly class Validator implements \Lcobucci\JWT\Validator
{
public function assert(Token $token, Constraint ...$constraints): void
{
if ($constraints === []) {
throw new NoConstraintsGiven('No constraint given.');
}
$violations = [];
foreach ($constraints as $constraint) {
$this->checkConstraint($constraint, $token, $violations);
}
if ($violations !== []) {
throw RequiredConstraintsViolated::fromViolations(...$violations);
}
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key