gesdinet/jwt-refresh-token-bundle
Symfony bundle to manage JWT refresh tokens for LexikJWTAuthenticationBundle. Stores and rotates refresh tokens via Doctrine ORM or MongoDB ODM (or custom object manager), with configurable TTL, security, and endpoints. Requires PHP 8.2+ and Symfony 6.4+.
LexikJWTAuthenticationBundle, making it a seamless fit for Symfony-based APIs relying on JWT for authentication. It aligns with Symfony’s security architecture (firewalls, user providers, event listeners)./token/refresh endpoint and config updates). No breaking changes to LexikJWTAuthenticationBundle.refresh_tokens table (ORM) or collection (ODM), requiring a migration. No complex joins or schema conflicts.cookie config or remove_token_from_body.single_use: true) prevent replay but require careful handling of token invalidation.RefreshToken entity.ttl_update: true adds write operations on every refresh, increasing DB load.token field)?single_use: true) required, or can long-lived tokens be used with ttl_update?scope, client_id) required for downstream systems?LexikJWTAuthenticationBundle. Works alongside:
firebase/php-jwt).LexikJWTAuthenticationBundle config for conflicts.gesdinet/jwt-refresh-token-bundle, doctrine/orm or mongodb-odm).config/bundles.php and config/packages/gesdinet_jwt_refresh_token.yaml.RefreshToken entity (ORM/ODM) and run migrations.security.yaml to include refresh_jwt firewall and api_refresh_token route.logout event for token invalidation.RefreshTokenInterface.UserProvider can integrate with your user loader./api/login, /api/token/refresh) are whitelisted in CORS config.single_use, ttl_update, or cookie-based tokens.RefreshToken entity (e.g., add ip_address field)./api/token/refresh.gesdinet/jwt-refresh-token-bundle and lexik/jwt-authentication-bundle for security patches.# config/services.yaml
Gesdinet\JWTRefreshTokenBundle\EventListener\RefreshTokenListener:
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onRefreshToken }
RefreshToken entity fields (e.g., used_at for single-use tokens).Access-Control-Allow-Origin headers are set.debug:router and debug:container for config validation.bin/console debug:event-dispatcher to inspect LogoutEvent listeners.refresh_tokens table if token volume exceeds 10M+ entries.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database downtime | Token validation fails | Use Redis as a fallback store for critical tokens. |
| Token table corruption | Lost refresh tokens | Regular backups; consider soft deletes (is_valid flag) instead of hard deletes. |
| Concurrent refresh attacks | Token exhaustion | Rate-limit `/api/token |
How can I help you explore Laravel packages today?