birdcar/authkit-laravel
birdcar/authkit-laravel is a Laravel authentication toolkit designed to simplify common auth setup and user flows. It offers a lightweight starting point for adding authentication to Laravel applications, with a small footprint, straightforward integration, and a minimal approach for projects seekin...
Authkit::actingAs(), actingAsGuest(), and Authkit::fake() make WorkOS-backed auth a fully offline, in-process concern in Pest/PHPUnit. A PM can now justify shipping SSO, SCIM/org sync, FGA, Vault, Audit Logs, invitations, API keys, Pipes, and Groups without carving out a paid third-party sandbox or a staging tenant in every CI run — directly reducing flaky builds, test runtime, and per-seat WorkOS sandbox costs.AuditLog::assertLogged(...) with real actor resolution and metadata sanitization), impersonation with the Impersonating event, org-scoped API keys, and Vault optimistic-locking ConflictException parity. These become testable acceptance criteria rather than promises, so "audit logging," "impersonation," and "secrets rotation" can move onto a roadmap with confidence.Gate checks, Authkit::currentOrganization(), $request->organization(), and the Pennant workos store behave identically to live login. That means PMs can sign off on authorization and feature-flag behavior in unit tests rather than manual QA passes.Authkit::fake(['fga', 'vault']) keeps unfaked managers on real code paths, so teams can adopt incrementally — useful when sequencing a migration across squads rather than mandating a big-bang test rewrite.authkit.http.transport, default laravel) means Http::preventStrayRequests(), Http::fake(), and Http::assertSent() work as expected, and production HTTP middleware/client events observe WorkOS calls like any other outbound request. That's a platform-consistency win PMs can point to when defending a "no special-case SDKs" architecture policy.Consider it when:
Gate, Pennant, HTTP client fakes, Http::preventStrayRequests()) and want WorkOS to behave like the rest of the framework.Look elsewhere when:
workos/workos-php 9.2.0 with no upgrade path, or you require the guzzle transport for existing middleware/telemetry reasons and don't want a configuration seam. (Both are supported — AUTHKIT_HTTP_TRANSPORT=guzzle opts out — but they add a decision to make.)final, and testing assertions now throw LogicException when called without faking first. That's a better failure mode, but it is a behavioral change for any test suite that relied on the previous undefined-method fatal or on final semantics.For executives: v2.1.0 closes the last real gap in buying auth instead of building it. Until now, adopting WorkOS meant our test suite either hit a live sandbox or skipped auth paths entirely — slow, flaky, and a recurring line item. With Authkit::fake() and actingAs(), every WorkOS surface we wrap is now testable offline in milliseconds, with no credentials and no network. Practically: faster CI, fewer escaped auth bugs, lower sandbox spend, and the ability to put audit logging, impersonation, and secrets management on the roadmap as verifiable commitments rather than aspirations.
For engineering: This is a testing release, and it's the one you'd have written. Authkit::actingAs($user, [...]) and actingAsGuest() inject synthetic workos sessions with no cookie, no JWKS fetch, and no SDK call — but claims flow through the exact contracts the real guard uses, so Gate, Authkit::currentOrganization(), $request->organization(), and the Pennant workos store all behave as they would in production. Authkit::fake() swaps manager bindings for typed in-memory fakes with scripting and assertions: FGA allow/deny with assertChecked, a stateful invitation registry, AuditLog::assertLogged(...) with real actor resolution and metadata sanitization, org-sync Bus capture plus completeSync(), user- and org-scoped API keys that authenticate through the real authkit-key guard machinery, a Vault KV store with version history and ConflictException parity (with the Vaulted cast and vault disk running real code paths over clearly-marked fake crypto), Pipes fixtures and scripted tokens with both business exceptions triggerable, and full Groups CRUD/membership/roles with the FGA cache-bust contract intact. Faking is opt-in per manager — Authkit::fake(['fga', 'vault']) leaves everything else live — so adoption can be incremental. Separately, WorkOS traffic now rides Laravel's HTTP client by default (authkit.http.transport, default laravel; guzzle to opt out), so Http::preventStrayRequests(), Http::fake(), and Http::assertSent() finally see these calls, and production middleware and HTTP client events observe them like any other outbound request. SDK retry, error-mapping, and JWKS caching are unchanged.
Two things to note before upgrading: manager classes that gained fakes are no longer final — each has a designed testing subclass guarded by an arch test, so any local subclassing assumptions should be re-checked. And calling a testing assertion without faking first now throws a LogicException naming the fix, instead of an undefined-method fatal; that's strictly better, but it will surface in any suite that was silently doing the wrong thing. We've also fixed compatibility with workos/workos-php 9.2.0, where the events poller now passes the required $events filter explicitly (empty = all types, same wire request as before) — worth pinning deliberately. Full guide: docs/testing.md.
How can I help you explore Laravel packages today?