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

Security Token Extractor Laravel Package

smartassert/security-token-extractor

Extract security tokens from incoming HTTP requests through one consistent API. This small PHP package keeps token parsing out of your controllers and middleware, so Laravel and other PHP applications can authenticate cleanly with less duplicated logic, clearer code, and easier testing.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package occupies a deliberately narrow seam in the request lifecycle: it answers "where is the token and what is its raw value" and nothing else. That is the correct decomposition for an auth pipeline — discovery, validation, and principal resolution should be separate concerns, and most homegrown Laravel auth middleware conflates all three into a 150-line handle() method. For a codebase already carrying custom guard logic or a non-standard token scheme (multiple header names, query-param fallback for webhooks, per-tenant token prefixes), this removes a recurring source of duplication. For a codebase that only ever reads Authorization: Bearer, Laravel's built-in $request->bearerToken() already covers the requirement and this package adds a dependency without adding capability.

Integration feasibility. The stated framework-agnostic API is the key property and also the key integration question. Laravel does not hand PSR-7 requests to middleware by default, so the package is only directly usable if it accepts PSR-7 ServerRequestInterface, offers a generic accessor interface we can implement against Illuminate\Http\Request, or is trivially adaptable. If it is PSR-7-only, plan for a 30–60 line adapter class plus a container binding; that is cheap, but it is work the README does not appear to promise. The MIT license and small surface area make this a low-ceremony evaluation — an afternoon spike should settle feasibility definitively.

Technical risk. The dominant risk is not code quality, it is project viability. Zero stars, zero dependents, and a last release in September 2023 mean no community validation, no downstream bug reports to learn from, and no evidence of ongoing maintenance. A single-maintainer package with no adoption can go quiet without anyone noticing. Mitigations are strong here because the package is small: the entire useful surface is plausibly a few hundred lines, so the exit cost of vendoring or reimplementing is measured in hours, not sprints. Secondary risks: PHP version and PSR version constraints may not align with our runtime; the "clear failure behavior" may be exceptions where our middleware expects nullable returns (or vice versa), which affects how errors map to 401 vs 400 responses; and token-in-query-parameter support, while useful for webhooks, deserves a deliberate policy decision because query-string tokens leak into access logs and referrers.

Key questions.

  • Does it accept PSR-7, a generic request abstraction, or both — and is there a documented adapter path for Illuminate\Http\Request?
  • Which token locations are supported, and can the location set be configured per-route rather than globally?
  • Does it distinguish missing from malformed tokens with distinct types, so we can return 401 vs 400 correctly and log them separately?
  • Does it return a typed value object or a raw string? A value object is easier to pass into validators without string-typing mistakes.
  • What are the PHP and PSR-7 version constraints, and do they match our current runtime?
  • Is there a test suite, and does it cover the malformed-token and multi-location cases?
  • Is there any signal of maintainer responsiveness (issues, PRs) in the last 12 months?

Integration Approach

Stack fit. Well-suited to a Laravel service that already has, or is about to build, custom authentication middleware — particularly multi-tenant APIs, webhook receivers, and services that accept tokens from more than one location. Poorly suited to a standard Laravel app using Sanctum or Passport with default bearer-token behavior; in that case the framework already owns this concern and the package is redundant.

Migration path. Treat this as an additive refactor, not a replacement. Identify every place in the codebase that currently reads a token out of the request (middleware, form requests, controllers, jobs that rehydrate requests). Extract those into the new abstraction behind a thin internal interface, so our code depends on our interface and the package is an implementation detail. That interface is the real deliverable — it makes the third-party dependency swappable and collapses the vendor risk to near zero.

Compatibility. Verify three things before committing: PHP constraint against our runtime and CI matrix, PSR-7 (or equivalent) constraint against whatever HTTP abstraction we already pull in, and exception hierarchy against our existing error-handling middleware so token failures produce the right status codes and do not get swallowed by a generic handler. Because the package is small, a failing constraint is more likely to be fixable by a fork than a blocker.

Sequencing.

  1. Spike (1–2 days). Install in a branch, write a Laravel adapter, prove extraction works against a real request in a test.
  2. Parallel run. Introduce the abstraction alongside existing token reading, with both paths active and a log assertion that they agree.
  3. Cut over one middleware or route group at a time; keep the legacy path behind a config flag.
  4. Retire the duplicated extraction code once parity holds across the route inventory.
  5. Vendor or pin. Decide explicitly between tracking upstream and vendoring the source in-repo; document the decision and the trigger for revisiting.

Operational Impact

Maintenance. Ongoing cost is low in absolute terms but the maintenance signal is poor. With no dependents and no recent release, we should assume we are the maintainers. The honest posture is: pin the version, vendor the source or keep a patched fork ready, and budget a few hours per year to review PHP version compatibility. Do not build a dependency-update policy that assumes upstream will respond to issues.

Support. No commercial support, no community to ask. Internal ownership must be explicit — a named engineer who understands the adapter and the exception mapping. Because the abstraction is thin, this is a documentation task more than a skills task: a short ADR explaining why we use it, what it does not do, and how to replace it.

Scaling. Effectively zero scaling concern. Token extraction is a constant-time string operation per request with no I/O, no state, and no caching layer. It will not be a throughput bottleneck at any realistic request volume. The only scaling-adjacent consideration is configuration growth if the set of accepted token locations expands per tenant — keep that configuration declarative and centralized rather than scattered across route definitions.

Failure modes. Three to design for explicitly. First, silent misconfiguration: if the location set does not match what clients actually send, every request fails auth and the blast radius is total; mitigate with a startup or deploy-time assertion that the configured locations are non-empty and a smoke test in the deploy pipeline. Second, exception leakage: malformed-token exceptions escaping to a generic 500 handler would turn a client error into an incident; verify mapping to 400/401 in integration tests. Third, ambiguity when multiple locations are populated — define precedence (header over query parameter, presumably) and test it, because conflicting tokens are exactly the case an attacker probes. Add structured logging on extraction failure that records the location attempted but never the token value.

Ramp-up. Very fast. A mid-level Laravel engineer should be productive within half a day given the adapter and ADR exist; the package's own surface is small enough to read end to end. The ramp-up cost sits almost entirely in understanding our adapter and error-mapping conventions, not the third-party code — which is another argument for keeping the adapter minimal and well-documented rather than letting it accrete logic over time.

Recommendation. Proceed with a contained spike. The architecture is sound and the exit cost is trivial, so the evaluation is cheap and reversible. The adoption metrics argue against treating this as a strategic dependency; adopt it as a small, vendored, interface-hidden utility, or reimplement the equivalent in an afternoon if the spike surfaces any constraint mismatch.

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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager