first commit

This commit is contained in:
2025-09-12 15:23:08 +08:00
commit a80c237bbb
117 changed files with 15628 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Lib\Jwt;
use Hyperf\Cache\Driver\DriverInterface;
use Lcobucci\JWT\Token;
use Lcobucci\JWT\Validation\Constraint;
use Lcobucci\JWT\Validation\ConstraintViolation;
use Psr\SimpleCache\InvalidArgumentException;
class BlackListConstraint implements Constraint
{
/**
* @param bool $enable
* @param DriverInterface $cache
*/
public function __construct(
private readonly bool $enable,
private readonly DriverInterface $cache
) {}
/**
* @param Token $token
* @return void
* @throws InvalidArgumentException
*/
public function assert(Token $token): void
{
if ($this->enable !== true) return;
if ($this->cache->has($token->toString())) throw ConstraintViolation::error('Token is in blacklist', $this);
}
}