Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jwt Refresh Token Bundle Laravel Package

ad3n/jwt-refresh-token-bundle

Symfony bundle to manage JWT refresh tokens alongside LexikJWTAuthenticationBundle. Supports Doctrine ORM or MongoDB ODM, adds refresh token generation/rotation and storage, plus endpoints and security integration for renewing access tokens securely.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/LexikJWT Integration: The bundle is designed as a Symfony bundle, leveraging LexikJWTAuthenticationBundle, making it a natural fit for Symfony-based applications already using JWT authentication. If the system relies on Laravel, this package is not directly applicable due to architectural mismatches (Symfony vs. Laravel ecosystems).
  • Token Management: Provides a structured way to handle refresh tokens, which is critical for secure OAuth2/JWT flows. If the system lacks a refresh token mechanism, this could be a high-value addition.
  • Doctrine Support: Works with Doctrine ORM/ODM, which is common in Symfony but may require adjustments in Laravel (e.g., Eloquent) or other ORMs.

Integration Feasibility

  • Laravel Compatibility: Low – The bundle is Symfony-specific and relies on Symfony components (e.g., LexikJWTAuthenticationBundle). A Laravel TPM would need to:
    • Evaluate alternative Laravel packages (e.g., tymon/jwt-auth, spatie/laravel-jwt-refresh-token).
    • Assess whether a custom implementation or Symfony-to-Laravel port is viable (high effort, high risk).
  • LexikJWT Dependency: If the system already uses LexikJWTAuthenticationBundle, integration is straightforward. Otherwise, adopting this bundle would require additional setup (JWT configuration, token storage, etc.).
  • Database Schema: Requires a refresh token storage mechanism (Doctrine entities). Laravel users would need to adapt this to Eloquent models or a custom storage layer.

Technical Risk

  • Symfony Lock-in: Tight coupling with Symfony components could limit flexibility if the system is Laravel-based or uses a different auth stack.
  • Maintenance Burden: The package has low stars (1) and no dependents, suggesting limited adoption. Risk of abandonment or breaking changes (last release in 2025, but no clear activity).
  • Security Risks: Refresh token management introduces new attack surfaces (e.g., token revocation, storage vulnerabilities). Must ensure:
    • Proper token expiration/rotation.
    • Secure storage (DB, Redis, etc.).
    • Protection against CSRF, replay attacks.
  • Testing & Validation: Limited test coverage (Scrutinizer shows ~80%, but real-world reliability is unproven). Requires thorough internal testing.

Key Questions

  1. Why Symfony? If the system is Laravel-based, is this bundle being considered for:
    • Potential future Symfony migration?
    • As a reference for a custom Laravel implementation?
  2. Existing Auth Stack:
    • Does the system already use LexikJWTAuthenticationBundle (Symfony) or an equivalent (e.g., tymon/jwt-auth in Laravel)?
    • What is the current refresh token strategy (if any)?
  3. Security Requirements:
    • Are there compliance needs (e.g., GDPR, SOC2) that dictate token storage/management?
    • What is the expected token lifetime and revocation policy?
  4. Performance:
    • Will refresh tokens be stored in DB (slow for high traffic) or Redis (faster, but adds complexity)?
  5. Fallback Plan:
    • If integration fails, what is the alternative approach (e.g., custom middleware, another package)?

Integration Approach

Stack Fit

  • Symfony Environments: High Fit – Designed for Symfony 5.4+, with LexikJWTAuthenticationBundle dependency. Ideal if:
    • The system is Symfony-based.
    • JWT auth is already implemented via LexikJWT.
  • Laravel Environments: Low Fit – Not natively compatible. Options:
    • Option 1: Use a Laravel-native package (e.g., spatie/laravel-jwt-refresh-token).
    • Option 2: Custom implementation (e.g., extend tymon/jwt-auth with refresh logic).
    • Option 3: Symfony microservice (if the system can decouple auth into a separate service).

Migration Path

  1. Assessment Phase:
    • Audit current authentication flow (JWT, sessions, OAuth).
    • Document refresh token requirements (lifetime, revocation, storage).
  2. Symfony Path (If Applicable):
    • Install gesdinet/jwt-refresh-token-bundle.
    • Configure LexikJWTAuthenticationBundle (if not already done).
    • Set up Doctrine entities for refresh tokens.
    • Implement token rotation logic (e.g., short-lived access tokens + long-lived refresh tokens).
  3. Laravel Path:
  4. Hybrid Approach:
    • If parts of the system are Symfony and others Laravel, consider:
      • Shared auth service (e.g., API gateway handling JWT).
      • Database schema alignment for refresh tokens.

Compatibility

  • Symfony:
    • High compatibility with Symfony 5.4+ and LexikJWT.
    • Doctrine ORM/ODM required (no native support for Eloquent or other ORMs).
  • Laravel:
    • No direct compatibility. Would require:
      • Middleware adaptation (Symfony’s EventDispatcher → Laravel’s Events).
      • Entity mapping (Doctrine → Eloquent).
      • Service container adjustments (Symfony’s DI → Laravel’s IoC).
  • Dependencies:
    • Requires PHP 7.4+ and Symfony 5.4+.
    • LexikJWTAuthenticationBundle must be installed (or equivalent in Laravel).

Sequencing

  1. Phase 1: Proof of Concept (PoC)
    • Set up a test environment (Symfony/Laravel).
    • Implement basic refresh token flow (issue, validate, rotate).
    • Test edge cases (expired tokens, revocation, concurrent logins).
  2. Phase 2: Integration
    • Symfony: Bundle installation + configuration.
    • Laravel: Custom implementation or alternative package.
    • Database: Schema updates for token storage.
  3. Phase 3: Security Hardening
    • Rate limiting on refresh endpoints.
    • Token binding (IP/user-agent checks).
    • Logging/auditing for token issuance/revocation.
  4. Phase 4: Monitoring & Optimization
    • Performance testing (DB vs. Redis storage).
    • Alerting for failed refresh attempts.
    • Documentation for devs (e.g., "How to revoke a token").

Operational Impact

Maintenance

  • Symfony:
    • Pros:
      • Bundled updates (via Composer).
      • Community support (LexikJWT has active maintenance).
    • Cons:
      • Doctrine dependency may require schema migrations if entities change.
      • Bundle updates could introduce breaking changes (monitor gesdinet/jwt-refresh-token-bundle releases).
  • Laravel:
    • Pros:
      • No Symfony lock-in if using Laravel-native alternatives.
    • Cons:
      • Custom code requires manual maintenance.
      • No official support (unlike Symfony bundle).

Support

  • Symfony:
    • LexikJWT has active issue tracking (GitHub).
    • Stack Overflow has answers for common problems.
    • Limited support for this specific bundle (low stars, no dependents).
  • Laravel:
    • Alternative packages (e.g., Spatie) have better support.
    • Custom solutions require internal documentation and on-call rotation for issues.
  • Key Support Risks:
    • Token revocation bugs (e.g., stale tokens in cache).
    • Performance bottlenecks (DB queries during refresh).

Scaling

  • Token Storage:
    • Database (Doctrine): Scales poorly under high refresh rates (N+1 queries).
      • Mitigation: Use Redis for token storage (e.g., store token hashes in DB, full tokens in Redis).
    • Redis: Better for high-throughput systems but adds cache invalidation complexity.
  • Concurrent Logins:
    • Must implement token binding (e.g., tie refresh tokens to user sessions/IP).
    • Revocation strategy: Single logout vs. per-device revocation.
  • Load Testing:
    • Simulate **10K+ concurrent
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui