web-token/jwt-signature
JWT Signature component from the web-token JWT Framework. Provides tools to create and verify JWT signatures in PHP. Read-only split repo; contribute via the main jwt-framework project. Full docs at https://web-token.spomky-labs.com/
tymon/jwt-auth (full-featured, Laravel-native).lcobucci/jwt (PSR-17 compliant, actively maintained).firebase/php-jwt (widely used, but less Laravel-optimized).
This package would duplicate effort unless used as a micro-optimization or for niche use cases.public function handle($request, Closure $next) {
$token = $request->bearerToken();
$parts = explode('.', $token);
$signature = new Signature(new HS256('secret'));
if (!$signature->verify($parts[0], $parts[1], $parts[2])) {
abort(401);
}
return $next($request);
}
lcobucci/jwt or firebase/php-jwt (advanced).class JwtSignatureService {
public function verify(string $token, string $secret, string $algorithm): bool {
$signature = new \WebToken\JWT\Signature\Signature(
\WebToken\JWT\Signature\Algorithm::create($algorithm, $secret)
);
return $signature->verify($token);
}
}
config or env; keys must be manually passed.lcobucci/jwt.| Risk Area | Assessment |
|---|---|
| Dependency Stability | High. Read-only repo with no independent roadmap. Bugs require fixes in the main framework, which may not align with your release cycle. |
| Security Risks | Medium. Correct usage mitigates risks, but: |
Auth::guard() or Sanctum. |
| Maintenance Burden | High. Custom integration logic may need updates if:lcobucci/jwt or firebase/php-jwt?
openssl_verify or libsodium for signatures?tymon/jwt-auth or work alongside it?lcobucci/jwt?lcobucci/jwt.tymon/jwt-auth or sanctum instead.jose (Python) or jjwt (Java) may be better.| Package | Pros | Cons |
|---|---|---|
lcobucci/jwt |
PSR-17 compliant, actively maintained, full JWT support. | No Laravel integrations. |
firebase/php-jwt |
Widely used, simple API. | Less maintained; no Laravel optimizations. |
spomky-labs/ssh-key |
Good for SSH-based signatures. | Overkill for standard JWT use cases. |
phpseclib/phpseclib |
Supports custom algorithms. | Heavyweight; not JWT-specific. |
tymon/jwt-auth, custom logic).lcobucci/jwt/firebase/php-jwt for your use case.$jwt = 'header.payload.signature';
$start = microtime(true);
$lcobucci = \Lcobucci\JWT\Parser::parse($jwt)->verify(...);
$timeLcobucci = microtime(true) - $start;
$start = microtime(true);
$signature = new \WebToken\JWT\Signature\Signature(...);
$timeCustom = microtime(true) - $start;
class JwtSignatureVerifier {
public function verify(string $token, string $secret, string $algorithm): bool {
$parts = explode('.', $token);
if (count($parts) !== 3) return false;
$signature = new \WebToken\JWT\Signature\Signature(
\WebToken\JWT\Signature\Algorithm::create($algorithm, $secret)
);
return $signature->verify($parts[0], $parts[1], $parts[2]);
}
}
How can I help you explore Laravel packages today?