- How do I install this package for Laravel JWT validation?
- Run `composer require web-token/jwt-signature-algorithm-rsa` to install. Since it’s a read-only RSA validator, pair it with an existing JWT library (e.g., firebase/php-jwt or tymon/jwt-auth) for token parsing. No Laravel-specific setup is required—just integrate the validator into your auth logic.
- Does this package support signing JWTs, or only validation?
- This package **only validates** RSA-signed JWTs (e.g., RS256/RS384/RS512). If your system needs to *sign* tokens, use a complementary library like `firebase/php-jwt` or `web-token/jwt-framework` for signing, then delegate validation to this package.
- Which Laravel versions and PHP versions are supported?
- The package requires **PHP 7.4+** (PHP 8.0+ recommended) and works with **Laravel 8+**. It has no hard Laravel dependencies, but modern PHP ensures compatibility with Laravel’s ecosystem. Test thoroughly if using older Laravel versions.
- How do I integrate this with Laravel’s Auth system?
- Create a custom middleware or extend Laravel’s `AuthServiceProvider` to validate tokens. Example: Inject the validator into middleware like `public function handle($request, Closure $next) { $validator = new RS256(); if (!$validator->validate($token, config('jwt.public_key'))) { abort(401); } return $next($request); }`.
- What key formats does this package support for RSA validation?
- This package requires **PEM-encoded RSA public keys** (standard format). Store keys securely (e.g., in `.env` or AWS KMS) and pass them to the validator. Example: `$validator->validate($token, file_get_contents('path/to/public.pem'))`.
- Will this conflict with existing JWT libraries like tymon/jwt-auth?
- No direct conflict, but replace only the validation logic. If using `tymon/jwt-auth`, override its validator or use this package as a fallback for RSA-signed tokens. Test thoroughly to avoid breaking existing HMAC or ECDSA flows.
- How do I test RSA-signed JWT validation in Laravel?
- Use PHPUnit to mock tokens and keys. Example: `$validator = new RS256(); $this->assertFalse($validator->validate('invalid.token', $publicKey));`. For integration tests, generate valid tokens with a signing library (e.g., `firebase/php-jwt`) and verify validation.
- Can I use this for production OAuth2 or API gateway workflows?
- Yes, but ensure secure key management (e.g., environment variables, KMS) and monitor for key rotation. This package is production-ready for validation-only use cases, but pair it with a signing library if your workflow requires both signing and validation.
- Are there alternatives to this package for RSA JWT validation?
- Yes. `firebase/php-jwt` supports RSA validation natively, while `web-token/jwt-framework` offers a full suite. This package is a **lightweight, RSA-only** alternative if you want to avoid bloating dependencies or need explicit control over validation logic.
- How do I handle key rotation or revocation in production?
- Store public keys in a secure config (e.g., `.env` or database) and update them dynamically. For revocation, implement a short-lived token cache or use a JWT blacklist service. Test key rotation by validating tokens signed with old and new keys in CI/CD.