hashnz/hawk-server-bundle
Symfony bundle that adds server-side Hawk HTTP authentication to your app. Validate Hawk Authorization headers, verify MACs, timestamps, and nonces, and protect routes with configurable credentials.
Architecture fit — poor as stated, because the premise is off. hashnz/hawk-server-bundle is a Symfony bundle, not a Laravel package. Bundles rely on Symfony's HttpKernel, DependencyInjection (Extension + CompilerPass), and config-tree machinery that Laravel never loads. Laravel consumes Symfony components (HttpFoundation, Routing, Console, etc.), not the bundle system, so there is no composer require + register-provider path here. The realistic deliverable is "read the Hawk verifier and port ~200–400 lines into Laravel middleware," not "install a dependency."
What is actually reusable. The server-side Hawk verification logic: parsing the Authorization: Hawk id="…", ts="…", nonce="…", mac="…", ext="…" header, canonicalizing the request string, recomputing HMAC-SHA256, constant-time MAC comparison, timestamp-skew rejection, nonce replay tracking, and optional payload-hash validation. That is genuinely useful as a reference implementation. Everything around it is dead weight in our stack.
Integration feasibility. Low as a dependency, moderate as source material. A fork-and-extract effort is measured in days (spike + security review + adapter + interop tests), not hours. The crypto itself is simple and well-documented; the risk is in the edges (payload hashing behind proxies, nonce storage, key lookup).
Technical risk — high, on several independent axes.
composer.json constraints will almost certainly conflict with PHP 8.2+ and modern Symfony components that Laravel pulls in. Expect transitive dependency hell if we try to install rather than vendor.Key questions to resolve before any code is written.
php and symfony/* constraints in composer.json, and what is the last commit date?payload hash, or MAC-only? Does it handle the ext field correctly (it is part of the MAC, a common implementation bug)?==? This is the single most common flaw in homegrown Hawk implementations.id interface we can bind to our key store?Stack fit. Laravel 10/11 on PHP 8.2+, likely with Sanctum or Passport already in place. The correct shape is a HawkServiceProvider registering a HawkAuthenticate middleware, a HawkCredentialRepository contract bound to our key store, and a HawkNonceStore bound to Redis. The bundle's DependencyInjection/ and Resources/config/ directories are discarded entirely; only the verifier is lifted.
Migration path. Do not attempt to register the bundle. Options, in order of preference:
app/Support/Hawk/ with a header comment attributing origin and license. Pinning to a SHA is mandatory — a floating branch on an unmaintained repo is an unpinned supply chain.Compatibility gotchas that will bite during integration.
Authorization headers are frequently stripped by nginx/FastCGI. Confirm fastcgi_param HTTP_AUTHORIZATION $http_authorization; or equivalent on every hop.$request->getContent(), not the parsed input.Bearer tokens on the same routes needs explicit middleware ordering and a clear precedence rule.Sequencing. (1) 1–2 day spike: read composer.json, read the verifier, answer the key questions above. (2) Security review sign-off on MAC comparison and nonce handling — no code merged before this. (3) Build-vs-adopt-vs-substitute decision with the business driver stated in writing. (4) Port with an interop test suite validated against an independent Hawk client (the npm or Ruby hawk libraries) — do not test only against our own implementation. (5) Shadow-mode rollout: log accept/reject decisions without enforcing for one release cycle, then enforce.
Maintenance. We own this permanently. There is no upstream cadence to ride, no CVE feed to monitor, and no one else to file a bug with. Budget a named internal owner and a standing dependency-review entry for the fork. Realistically a few hours per quarter plus the initial hardening.
Support. Zero vendor, zero community, zero Stack Overflow surface. The runbook is ours to write, and it must include the canonical string format, the clock-skew policy, the nonce TTL, and a "how to debug a 401" section — otherwise every auth failure becomes an escalation to whoever wrote the middleware.
Scaling. The stateless part (HMAC verification) scales horizontally with no issue — it is pure CPU and cheaper than a database round-trip. The part that does not scale naively is the nonce replay cache: it requires a shared, low-latency store (Redis) with TTL equal to the skew window, typically 60s. An in-process or per-node nonce cache silently degrades replay protection to per-node scope, which is a security regression that will never show up in a functional test.
Failure modes to design for explicitly.
Ramp-up. Nontrivial. Nobody on a typical Laravel team has encountered Hawk; it is not in anyone's muscle memory. Onboarding requires the runbook, a client-side signing helper for local development, and debug tooling — the ext field, which is MAC'd and free-form, is the one genuinely nice affordance here and should carry a request correlation ID. Expect a day of ramp-up per engineer who touches it, and more for whoever is on call the first time a 401 storm hits.
Bottom line for the roadmap: treat this repo as a specification and reference implementation, not a dependency. Adopt only if a partner interop requirement forces Hawk; otherwise the rational move is to standardize on an auth mechanism the team and the ecosystem already understand.
How can I help you explore Laravel packages today?