Weave 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

Simplejwt Laravel Package

kelvinmo/simplejwt

SimpleJWT is a PHP library for JSON Web Tokens, signatures, and encryption. It supports JWK and COSE keys, HMAC/RSA/ECDSA/EdDSA signatures, key management, and AES encryption. Requires PHP 8+ with gmp, hash, openssl, and sodium for EdDSA/X25519.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API Security & Authentication: Enables JWT-based auth for Laravel APIs, replacing legacy session-based or basic auth systems. Supports OAuth2 flows (e.g., token generation/validation for /oauth/token endpoints).
  • Microservices & Decoupling: Facilitates secure inter-service communication via signed/encrypted JWTs (e.g., service-to-service APIs, event payloads).
  • Build vs. Buy: Avoids reinventing JWT logic (e.g., no custom PHP libraries or Node.js bridges). Reduces tech debt vs. maintaining a homegrown solution.
  • Compliance & Standards: Aligns with RFC 7519/7515/7516 for interoperability (e.g., integrating with third-party identity providers like Auth0, Okta).
  • Security Risk Posture (new in v1.1.3): The zip:DEF decompression path now validates decompressed data length before use. This closes a decompression-bomb / DoS vector where a maliciously crafted JWE payload could force excessive memory allocation. Relevant to any decision involving accepting JWEs from untrusted parties (partner integrations, public webhooks, multi-tenant token exchange) — treat as a mandatory patch floor, not a feature.
  • Roadmap Priorities:
    • Phase 0 (immediate): Upgrade to v1.1.3+ everywhere JWE with zip:DEF is enabled. Pin a minimum version in composer.json so no environment can fall back to a vulnerable build.
    • Phase 1: Replace firebase/php-jwt (if used) with this package for consistency.
    • Phase 2: Implement JWE (JSON Web Encryption) for sensitive data (e.g., PII in API responses) — now gated behind the v1.1.3 fix.
    • Phase 3: Explore EdDSA/X25519 for post-quantum-resistant keys (future-proofing).

When to Consider This Package

  • Adopt if:

    • Your Laravel app needs JWT support (auth, APIs, microservices).
    • You require modern algorithms (e.g., EdDSA, X25519, AES-GCM) beyond basic HMAC/RSA.
    • You want JWE encryption for confidential data (e.g., encrypted tokens or payloads).
    • Your team lacks cryptography expertise (package handles edge cases like key rotation, invalid tokens).
    • You're using PHP 8.0+ (required for compatibility).
    • You need a patch-level security fix now: v1.1.3 addresses unbounded decompression on zip:DEF. If you already accept JWEs from external callers, upgrading is cheaper than building your own payload-size guards.
  • Look elsewhere if:

    • Your stack uses non-PHP languages (e.g., Go/Rust; consider native JWT libs).
    • You require OIDC-specific features (e.g., token introspection; pair with league/oauth2-server).
    • Your project is PHP 7.x (unsupported; upgrade or use firebase/php-jwt).
    • You need enterprise support / SLA-backed CVE response (no commercial backing; self-hosted only). v1.1.3 shows the maintainer does ship security fixes, but turnaround is best-effort — factor that into risk acceptance for internet-facing token ingestion.
    • You need auditable security advisories (no formal CVE/GHSA process observed for this fix; track releases manually or via dependency scanners).

How to Pitch It (Stakeholders)

For Executives:

*"This package modernizes our authentication stack by replacing ad-hoc JWT solutions with a RFC-compliant, actively maintained library. It enables:

  • Secure APIs (JWT for microservices, third-party integrations).
  • Data protection (JWE encryption for sensitive payloads).
  • Future-proofing (supports post-quantum algorithms like EdDSA).
  • Reduced exposure: the latest release (v1.1.3) patches a denial-of-service weakness in compressed encrypted tokens — the kind of flaw that can take an API down if we accept tokens from partners. Cost: Free (BSD license); Risk: Minimal (widely used in production). Recommend a routine patch upgrade this sprint, plus adoption for our API-first roadmap."*

For Engineering:

*"SimpleJWT is a drop-in replacement for firebase/php-jwt with critical upgrades:

  • Algorithms: Supports EdDSA, X25519, AES-GCM (missing in legacy libs).
  • JWE: Encrypts tokens/payloads (e.g., for GDPR-compliant data handling).
  • Key Management: Simplifies PEM/JWK integration (e.g., load keys from files or secrets managers).
  • Performance: Optimized for PHP 8.0+ (faster than firebase/php-jwt in benchmarks).
  • Security hardening (v1.1.3): zip:DEF decompression now validates output length — mitigates decompression-bomb DoS on JWE inputs. Non-breaking, no API changes; a pure patch bump. Migration Path:
  1. Replace firebase/php-jwt with kelvinmo/simplejwt in composer.json (require ^1.1.3 minimum).
  2. Update token generation/validation to use SimpleJWT\JWT/SimpleJWT\JWE.
  3. Test with HS256/RSA256 first, then enable advanced algorithms.
  4. If you already use JWE with zip:DEF, bump the constraint and re-run payload round-trip tests against large/compressed inputs. Trade-offs: No CLI tools (but kelvinmo/jwkstool exists separately). Still no upstream max-payload knob surfaced publicly — consider enforcing request body size limits at the gateway as defense-in-depth."*
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.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table