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

Laravel Jwt Laravel Package

a2workspace/laravel-jwt

JWT authentication for Laravel: issue and validate JSON Web Tokens for stateless API auth. Plugs into Laravel's auth guards and middleware to protect routes, with configurable signing keys, token lifetimes, and claims for flexible, token-based access control.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

What this package actually is. The evidence from the release notes is decisive: 2.2.0 changes exactly one thing — the jwt-auth constraint to ^2.2. The setup instructions reference Tymon\JWTAuth\Providers\LaravelServiceProvider, php artisan jwt:secret, and config/jwt.php. In other words, this is a thin convenience shim over tymon/jwt-auth, not a JWT implementation in its own right. Its value is boilerplate elimination (a pre-wired api guard, sane TTL defaults, a suggested controller shape); its risk surface is inherited wholesale from the upstream package. A TPM should evaluate and budget for tymon/jwt-auth and treat this as a preset, not a platform.

Architecture fit. Good for the narrow target: a Laravel monolith or API-only backend with an Eloquent User model, session-less bearer-token auth, and a client that can persist and replay tokens (SPA, mobile, service-to-service). Poor fit for: multi-tenant or OIDC/SAML identity, external IdP integration, serverless/edge deployments (the blacklist requires shared cache state), or anything needing per-request revocation guarantees without Redis. The documented extension points (jwt.providers.storage, claim factory, getJWTCustomClaims()) are adequate for a single-service deployment and thin for a federated one.

Integration feasibility. Low effort, bounded risk. It is a Composer dependency plus four edits: publish config, generate a secret, define an api guard in config/auth.php, implement JWTSubject on User. The login/refresh/logout controller is a known pattern with a clear smoke test (POST /api/login → token, GET /api/me with Authorization: Bearer → 200). Estimate days, not weeks, for a team already on Laravel 9+. The main friction is not code — it is the decision of whether to take a dependency in the authentication path.

Technical risk. Ranked:

  1. Supply chain / bus factor. 4 stars, single opaque vendor namespace (a2workspace), score 0.32, one release in the observed window. Adding an unaudited third-party package to the auth path is the single largest risk here. Mitigation: depend on tymon/jwt-auth directly and copy the guard config internally, or vendor the shim with a committed lockfile and a named internal owner.
  2. Abandonment. Upstream jwt-auth 2.x is itself a slow-moving line; this wrapper tracks it with a lag. Neither has a visible security-response commitment.
  3. Config drift. The 2.x rework changed config keys (providers.*.storage, providers.jwt.lock_subject, required_claims). A stale published config/jwt.php boots fine and then fails at validation time — a deploy-time landmine that surfaces as a production 401 storm.
  4. Cached config vs. .env. config:cache bakes JWT_SECRET in; missing-secret incidents are almost always stale cache, not bad code.

Key questions for the vendor/owner before commitment.

  • Does this package ship any code beyond config and a guard preset, or is it purely a distribution of tymon/jwt-auth defaults?
  • Who is the named maintainer, and what is the process for a PHP/Laravel security advisory?
  • Is there a supported PHP/Laravel version matrix, and does it extend to the versions on our upgrade roadmap?
  • Can we fork this into our own namespace under MIT without functional loss? (If yes, the decision is low-risk.)
  • What is our exit path to tymon/jwt-auth, Sanctum, or Passport, and what would force it?

Integration Approach

Stack fit. Compatible with Laravel's native guard and middleware contract, which is the entire point — routes use auth:api, controllers use the guard (not the facade) so refresh() and logout() semantics stay intact. That means the blast radius of adopting or later removing it is confined to config/auth.php, config/jwt.php, app/Models/User.php, and the auth controller. Keep it that way: do not wrap the guard in an internal abstraction. Wrapping reliably breaks refresh semantics and buys nothing.

Migration path (inbound). Greenfield: composer require a2workspace/laravel-jwt:^2.2, publish, jwt:secret, define the api guard, add JWTSubject, ship login/refresh/me/logout. Brownfield with Sanctum or Passport: do not run two token schemes on the same routes. Introduce the jwt guard alongside existing guards, migrate one API surface (typically the mobile client) first, and only retire the old guard after the refresh/expiry behaviour has been observed for a full token lifecycle.

Compatibility checks, in order. (1) PHP and laravel/framework versions against jwt-auth 2.2's constraints — the release's only change is this pin, so this is the actual gate. (2) JWT_SECRET provisioning in every environment including CI and preview deploys. (3) Cache driver: file is disqualifying in production if the blacklist is enabled; require Redis or the database store. (4) Proxy/ingress header limits against expected claim size.

Migration path (outbound). Because the package is a preset, the exit is mechanical: keep config/jwt.php and the guard as published artifacts committed to our repo, point composer.json at tymon/jwt-auth directly, delete the shim. Do the reverse for any vendor change. Practically, this argues for adopting the internal-config route from day one.

Sequencing.

  1. Spike (1–2 days) in a throwaway branch: full login → me → refresh → logout with blacklist enabled against Redis.
  2. Decision gate: keep the shim vs. own the config. Default to owning it unless the shim demonstrably saves maintenance.
  3. Integration tests for the four endpoints plus an expiry test using Carbon::setTestNow() / setTTL(0) — never sleep().
  4. Secret management and log redaction of the Authorization header landed before any production route is exposed.
  5. Roll out one client surface, monitor 401 rates, then expand.

Operational Impact

Maintenance. Near-zero code maintenance if the shim is adopted as-is, but non-zero tracking maintenance: someone must watch tymon/jwt-auth 2.x releases and re-diff the published config. That owner must be named, not implied. Budget a recurring quarterly review item, plus an upgrade runbook entry: vendor:publish --force to a scratch directory, diff against ours, and specifically check providers.*.storage, providers.jwt.lock_subject, and required_claims.

Support. Community-only, no SLA, negligible community mass (4 stars). Support burden lands internally. Ramp-up is the mitigating factor: any Laravel developer who has used jwt-auth is productive in a day, and the failure surface concentrates in two files — config/jwt.php and the api guard in config/auth.php. Document exactly that: "401 with a visibly valid token → check those two files first."

Scaling. Stateless verification scales horizontally without issue. The scaling constraint is the blacklist store, not the crypto: every logout/refresh becomes a cache read, so Redis capacity and availability become auth-path dependencies. Token size matters at the edge — large custom claims breach the ~8 KB header limit and produce intermittent 400s that look nothing like auth failures, so keep claims minimal and resolve roles from the user lookup.

Failure modes to instrument and alert on.

  • Config-cache drift: .env changed, config:cache not cleared → blanket 401s after deploy. Alert on a step-change in 401 rate immediately post-deploy.
  • Cache flush: silently un-blacklists every logged-out token. Treat cache eviction as a security event, not a performance event.
  • Refresh replay: with blacklist_enabled = true, clients that don't persist the new token start throwing TokenBlacklistedException. Set refresh_ttl meaningfully above ttl, and raise blacklist_grace_period above 0 to survive immediate post-issue refresh.
  • Long-running processes: queue workers and Octane retain a resolved guard across jobs and leak tokens between them. Require explicit setUser/setToken or guard reset per job.
  • Clock skew: nbf/iat drift between issuer and verifier shows up as 401s in one environment only; configure jwt.leeway.
  • 401 vs. 400 confusion: distinguish TokenExpiredException (client should refresh) from JWTException/TokenInvalidException via a renderable handler, or clients will retry wrongly and amplify the incident.

Ramp-up. One to two days for a Laravel-fluent engineer; the documented gotcha list above is the entire training material. The non-obvious skills to transfer are blacklist/cache coupling, worker token hygiene, and the deploy-time config discipline — all operational, not architectural.

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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel