web-token/jwt-encryption-algorithm-pbes2
Adds PBES2 password-based encryption algorithms for JWT/JWE in the web-token stack. Enables PBES2-HS256+A128KW, PBES2-HS384+A192KW and PBES2-HS512+A256KW support for secure key wrapping when encrypting tokens.
web-token/jwt-encryption-algorithm-pbes2 package enables PBES2 (Password-Based Encryption Scheme 2) for JWT key encryption, a niche but critical requirement for high-security, password-derived key management in token-based authentication systems. It fits architectures where:
tymon/jwt-auth or laravel/sanctum) lacks native PBES2, making this package a specialized extension for scenarios where:
web-token/jwt-framework (widely used in PHP JWT ecosystems).tymon/jwt-auth).web-token/jwt-framework (≥v1.4.0) or firebase/php-jwt (≥v6.0.0) for JWT parsing.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Security Misconfiguration | High | Validate PBES2 parameters (e.g., iteration count, salt length) per RFC 8037. |
| Performance Bottlenecks | Medium | Benchmark PBES2 vs. AES-256-GCM in staging; consider caching derived keys for short-lived tokens. |
| Lack of Maintenance | Medium | Fork the repo or engage the maintainer for long-term support. Monitor for CVE updates. |
| Interop Issues | Low | Test with multiple JWT libraries (e.g., lucadegasperi/oauth2-server) for edge cases. |
| Deprecation Risk | Low | PBES2 is standardized (RFC 8037), but PHP’s crypto landscape may evolve (e.g., libsodium). |
paragonie/sodium_compat) achieve similar goals with better performance?tymon/jwt-auth or laravel/sanctum with PBES2 encryption.web-token/jwt-framework directly (bypassing Laravel’s auth layer for full control).spomky-labs/clarify for JWT management with PBES2 support.composer require web-token/jwt-encryption-algorithm-pbes2 web-token/jwt-framework
web-token/jwt-framework is used (e.g., Symfony, Lumen, standalone APIs).HS256, RS256).Encrypter facade to abstract key derivation logic.use WebToken\JWT\Encryption\Algorithm\PBES2;
use WebToken\JWT\Encryption\Key;
$key = new Key('password-derived-key', 'base64-encoded-salt');
$algorithm = new PBES2($key, 10000, 256); // iterations, key length
$token = $jwt->encrypt($payload, $algorithm);
web-token/jwt-framework, firebase/php-jwt (≥v6.0.0).lcobucci/jwt (<v3.0) lacks PBES2.alg header is set to PBES2-HS256 or PBES2-HS512.// app/Providers/AuthServiceProvider.php
$this->app['auth.jwt']->setAlgorithm(new PBES2($key, $iterations));
How can I help you explore Laravel packages today?