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

Hmac Authentication Bundle Laravel Package

gremo/hmac-authentication-bundle

A Symfony bundle for HMAC request authentication. It signs and verifies API requests using shared secrets, timestamps, and nonces, integrating with Symfony Security to protect stateless REST endpoints from tampering and replay attacks.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. Poor, and the mismatch is structural rather than cosmetic. This package is a Symfony bundle, not a Laravel package. It hooks into Symfony's security layer (firewall listener / authentication provider) and relies on Symfony's DependencyInjection, EventDispatcher, and HttpFoundation contracts. Laravel's auth surface is entirely different (middleware pipeline + guards + service container with different binding semantics). There is no Illuminate\Support\ServiceProvider, no configuration publishing, no facade — nothing a Laravel app can composer require and boot. The only genuinely reusable asset is the HMAC canonicalization scheme (which request components are signed, in what order, with what encoding), which is a specification, not an integration.

Integration feasibility. Two options, neither of which is "install the package":

  1. Extract-and-port — read the bundle's canonical string construction and verification routine, reimplement as a ~150–300 LOC Laravel middleware using hash_hmac, hash_equals, a timestamp-window check, and a nonce replay cache. Low effort, full control, no dead dependency.
  2. Sidecar — run the Symfony bundle in a thin gateway in front of the Laravel app. High operational cost for a small security primitive; hard to justify.

Installing it directly into a Laravel app is not viable without pulling Symfony components and hand-wiring a listener into Laravel's kernel — an anti-pattern that trades a 200-line middleware for a permanent dependency liability.

Technical risk. High, driven by three independent factors:

  • Abandonment. Last release 2019-06-05 — roughly six years stale. It predates Symfony 5/6/7 and PHP 8.x. Composer constraints almost certainly conflict with a modern stack (verify the composer.json require block before anything else).
  • Security-critical code with no scrutiny. 5 stars, 0 dependents, no visible external audit. HMAC verification is exactly the class of code where a subtle flaw — non-constant-time comparison, missing replay protection, signing the path but not the query string, no body-integrity check — is silently exploitable. Unmaintained crypto-adjacent code is a supply-chain liability, not an asset.
  • No ecosystem signal. Zero dependents means no downstream has validated it in production; there is no failure corpus to learn from.

The mitigating factor is that HMAC request signing is a well-understood, small primitive. The risk is in the dependency, not in the problem. Reimplementing removes nearly all of it.

Key questions to answer before any decision:

  • What exactly enters the canonical string — HTTP method, path, query, body hash, Content-Type, timestamp, nonce? Is the body covered at all?
  • Is the signature comparison constant-time (hash_equals), or a naive ==?
  • Is there replay protection (nonce store + TTL)? Where does it live, and what happens when it's unavailable?
  • Is the timestamp window configurable, and what is the default skew tolerance?
  • Which hash algorithm, and is it configurable/upgradeable?
  • How are per-client secrets provisioned, stored, and rotated? Is there key-versioning to allow overlap during rotation?
  • What PHP and Symfony versions are declared? Any deprecated API usage that would need rewriting anyway?
  • License terms (likely MIT — confirm) if we copy logic rather than depend.

Integration Approach

Stack fit. Treat this repository as a reference implementation and interop spec, not a dependency. The deliverable is a first-party Laravel middleware: verify signature → check timestamp within window (e.g. ±300s) → check nonce against Redis with TTL ≥ window → resolve client secret from a api_clients table → attach an authenticated principal to the request. Pair it with a Laravel guard or a lightweight Request::setUserResolver so existing authorization (policies, gates) works unchanged.

Migration path. Four phases:

  1. Spec extraction — document the bundle's canonical string byte-for-byte from source, including encoding and separators. This is the compatibility contract if any existing clients already sign this way.
  2. Middleware + conformance tests — implement, then pin behavior with test vectors generated from the original algorithm (including negative cases: tampered body, expired timestamp, replayed nonce, wrong secret).
  3. Shadow mode — deploy in log-only mode alongside existing auth; compare accept/reject decisions against real traffic for 1–2 weeks.
  4. Enforce + cutover — flip to blocking, then retire the legacy path.

If no clients exist yet, skip the compatibility constraint entirely and design the canonicalization to current best practice (sign method + path + sorted query + SHA-256 body hash + timestamp + nonce).

Compatibility. Target Laravel 10/11/12 on PHP 8.2+. The original bundle likely declares PHP 7.x and Symfony 3/4 — assume a hard conflict and plan not to resolve it. Prefer a maintained alternative (e.g. a current HMAC auth package with recent releases) if one passes review; otherwise the in-house middleware is the lower-risk path.

Sequencing. Do the dependency/licence review and spec extraction first — one day of work that either kills the option or scopes it. Then middleware, then shadow mode, then client onboarding and secret provisioning, then enforcement. Client key distribution is the long pole; start it early and in parallel with the code.

Operational Impact

Maintenance. If adopted as a dependency: effectively zero upstream maintenance, which converts to 100% internal ownership the moment a PHP or Symfony upgrade lands — you inherit a fork whether or not you plan to. If reimplemented: ~200 lines of first-party code with your own tests, which is cheaper to own over a 3-year horizon than an unmaintained transitive dependency.

Support. None available. No maintainer responsiveness, no issue triage, no security disclosure channel that would reach you in time. Any CVE-class issue in this code path is yours to find and patch. For authentication code, that is the decisive operational fact.

Scaling. The verification path is stateless and cheap — CPU-negligible per request, horizontally scalable with no coordination. The only stateful component is the nonce replay cache; Redis with TTL equal to the timestamp window scales fine and is already in most Laravel stacks. Do not put the nonce store in MySQL on the hot path.

Failure modes to design for explicitly:

  • Clock skew — client or server drift causes mass 401s. Mitigate with a documented window (≥5 min), server NTP, and a distinct error code so clients can diagnose.
  • Nonce store outage — decide fail-open vs fail-closed in advance. For auth, fail-closed is correct, but it means Redis becomes a hard dependency of the API; state that in the SLA.
  • Secret rotation without overlap — rotation windows must support two valid secrets per client (key versioning) or you get synchronized outages.
  • Body not covered by the signature — if the original scheme omits the payload, an attacker can replay a valid signature with a swapped body. Confirm and close this before enforcing.
  • Silent misconfiguration — an empty or default secret in config yields forgeable requests with no error. Fail fast at boot if any client has a null/weak secret.
  • No built-in rate limiting or brute-force protection — signature verification alone doesn't stop replay attempts; layer Laravel's throttle middleware on top.

Ramp-up. Low for the concept (HMAC signing is standard), moderate for the porting work (half a sprint including tests), and non-trivial for client onboarding — every integrating team needs the canonicalization spec, a test-vector fixture, and a sandbox. Budget documentation and a reference client SDK snippet; that, not the middleware, is where integration friction concentrates.

TPM recommendation. Do not take a production dependency on this package. Use it as a specification source, ship a first-party Laravel middleware with conformance tests, and record the decision as "reference-only, no runtime dependency." The package's low score, six-year staleness, and zero dependents align with that call; the underlying primitive is simple enough that building it is the cheaper and safer option.

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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums