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

Api Guard Laravel Package

chrisbjr/api-guard

API Guard is a Laravel package for API key authentication. It lets you generate and manage API keys, protect routes with middleware, and authenticate requests via configurable headers or query parameters, with hashed key storage and easy integration.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • Conventional Laravel 5.x package shape: a service provider, a route middleware (auth.api), an Eloquent model plus published migration for an api_keys table, and a trait mixed into the User model for key generation/association. No external services, queues, or event dependencies.
  • Fits the "single-table, static credential" pattern: a key is minted, stored, and validated per request via header (or query string). This is a machine-to-machine/shared-secret model, not a delegated-authorization model — no scopes, no token exchange, no refresh.
  • Because it is a thin layer over Eloquent + middleware, it is more accurately evaluated as a reference implementation than as a dependency. The whole surface area is small enough to re-implement in a day.

Integration feasibility

  • Low friction on Laravel 5.1–5.4 (its native era). Medium-to-high friction on Laravel 8+; treat "drop-in" as false until proven. Concrete breakpoints to verify: use of the removed str_random() helper (Laravel 6), reliance on other deprecated str_/array_ helpers, middleware alias registration differences ($routeMiddleware vs Kernel/bootstrap/app.php), and any Auth::guard() assumptions.
  • PHP 8.x: syntax likely parses, but the package predates PHP 7.2 and has no CI matrix — "it runs" is not "it is correct." There is no test suite signal to lean on.
  • MIT license means forking and hardening is legally unencumbered; the cost is ownership, not permission.

Technical risk

  • Lifecycle risk (highest): last release October 2016. No security patches, no PHP/Laravel compatibility guarantees, effectively a single-maintainer abandoned project. Zero dependents in the dataset is a weak ecosystem-adoption signal, not a quality signal.
  • Credential-handling risk: the implementation stores API keys in plaintext and relies on an active boolean rather than expiry, rotation, or hashing. A database read (backup, replica, log, support dump) yields usable credentials. No built-in rate limiting or attempt throttling, so key enumeration/brute force is bounded only by whatever you add at the edge.
  • Observability risk: no audit trail on issuance or use; incident response ("which client used this key, when?") requires custom instrumentation.
  • Query-string acceptance: keys passed as ?api_key= leak into access logs, proxies, and browser history.

Key questions

  1. Is the requirement machine-to-machine shared secrets, or user-delegated access? If delegated, this package is the wrong shape entirely — go to Sanctum or Passport.
  2. Which Laravel and PHP versions are actually in scope? A legacy 5.x app changes the calculus from "replace" to "contain."
  3. Do compliance or customer contracts require key expiry, rotation, scoping, or hashed-at-rest storage? Any "yes" disqualifies the package as-is.
  4. Who owns the fork — and is that cheaper than the one-sprint cost of migrating to Sanctum?
  5. How many client integrations exist, and can they all be re-issued keys on a coordinated schedule?

Integration Approach

Stack fit

  • Appropriate only for a legacy Laravel 5.x application needing minimal, short-lived API auth, or as a starting reference for an in-house middleware. Not appropriate as a new dependency in a greenfield or actively upgraded application.
  • If the target stack is Laravel 8+, the recommendation is to skip integration and adopt Sanctum (first-party, hashed token storage, abilities, expiration, actively maintained) or Passport (if full OAuth2 is required). Both are supported first-party packages with a migration story; api-guard has neither.

Migration path

  • Phase 0 — Contain (if already in production): vendor the fork, pin the commit, add hashed key storage (store hash('sha256', $key), compare on lookup), add an expires_at column, enforce header-only transmission, and add per-key rate limiting at the middleware or gateway layer.
  • Phase 1 — Bridge: build an adapter middleware that resolves credentials against both the legacy api_keys table and the new personal_access_tokens table. This enables zero-downtime cutover.
  • Phase 2 — Dual-issue: issue Sanctum tokens to all clients; keep legacy keys valid for a defined deprecation window with telemetry on last-used timestamps.
  • Phase 3 — Retire: disable legacy validation, then drop the table and trait after a full consumption cycle with no legacy hits.

Compatibility

  • Validate before committing: PHP version vs. package syntax; Laravel version vs. middleware registration and helper usage; database driver and collation for the key column; whether the active flag semantics match your revocation expectations. Add an index on the key column if absent — likely a full-table scan per request otherwise.
  • Confirm package auto-discovery works (extra.laravel) on the target Laravel; on 5.4-and-earlier-era packages this is usually present but should be verified.

Sequencing Client inventory → threat-model sign-off on plaintext storage → fork/harden or decide to migrate → bridge middleware → key re-issue campaign → deprecation telemetry → table drop. Migrate before any Laravel major-version upgrade; upgrading Laravel first will surface this package's compatibility debt at the worst possible moment.

Operational Impact

Maintenance

  • Upstream maintenance is zero. Assume no patches, ever; every fix is internal. Budget ongoing ownership: a security review and dependency-compatibility check per Laravel/PHP upgrade cycle, plus ad-hoc work for credential incidents.
  • Codebase is small, so the code maintenance is trivial; the risk maintenance is not.

Support

  • No vendor, no support contract, no issue-triage channel. Onboarding documentation is a README from 2016. Institutional knowledge will live with whoever forks it — a bus-factor of one unless documented.

Scaling

  • Per-request database lookup for key validation. Fine at low-to-moderate API volumes; add a short-TTL cache (Redis) keyed on the hashed key if request rates are high, at the cost of delayed revocation.
  • Stateless by design — horizontal scaling is unproblematic. No shared mutable state beyond the api_keys table.

Failure modes

  • Database unavailable → total auth outage: no fallback path; every API call fails closed (which is correct, but worth stating as an availability dependency).
  • Revocation lag: with any caching layer, a deactivated key remains valid until TTL expiry. Choose TTL against revocation SLA.
  • Credential exposure: plaintext storage means a read-only DB compromise, replica leak, or backup mishandling is a full API compromise. High blast radius, no compensating control.
  • Missing index → latency cliff: unindexed key lookup degrades linearly with client count.
  • Key leakage via logs: query-string transmission writes credentials into reverse-proxy and application logs.
  • Enumeration: no throttling means keyspace probing is limited only by entropy of key generation and edge controls.

Ramp-up

  • Low technical ramp-up: one middleware, one model, one migration — an engineer is productive in under a day.
  • Higher organizational ramp-up: the security posture must be re-established internally, and the migration-to-Sanctum decision requires product and security sign-off rather than an engineering call. The 2016 release date is the single most important fact in this evaluation; treat any adoption as a fork-and-own commitment, not a dependency addition.
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