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

Laravel Keycloak Web Guard Laravel Package

vizir/laravel-keycloak-web-guard

Laravel authentication guard that signs users in to your web app through Keycloak. It handles login, logout, token refresh, and role-based route protection, delegating identity to Keycloak via OpenID Connect with minimal configuration and no custom auth code to maintain.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package targets a narrow but legitimate slot: server-rendered Laravel applications (Blade/Livewire/Inertia-with-session) that delegate authentication to Keycloak via the OIDC Authorization Code flow. It plugs into Laravel's native Auth extension points — a custom guard plus a user provider configured in config/auth.php — so it does not fight the framework. It is a poor fit for stateless API backends, mobile clients, or SPA-first architectures; those need a token-validation guard (the sibling API-oriented package) or a BFF pattern. Confirm the intended topology before treating this as a candidate at all.

Integration feasibility. Mechanically low-effort: Composer install, publish config, set realm/client/base-URL/redirect-URI environment variables, register the guard and provider, attach middleware to the web route group. The integration surface is small, which caps the blast radius of adoption. The real feasibility gate is not code volume but version currency — the repository is archived, the score (~4.95/10) reflects that, and Composer constraints almost certainly predate the Laravel 10/11 and PHP 8.2+ era. Treat "does it install against our target framework version" as a go/no-go spike, not an assumption.

Technical risk. The dominant risk is lifecycle, not engineering: an archived package receives no CVE response, no OIDC spec corrections, and no dependency bumps, while its transitive tree (HTTP client, JWT/JOSE libraries, framework constraints) continues to drift. Secondary risks are protocol-level: ID-token signature and nonce/state validation, PKCE support, refresh-token rotation, RP-initiated logout, and how tokens are persisted in the session (server-side session storage is acceptable; cookie storage is not). Third is Keycloak coupling — behavior changes across Keycloak's WildFly→Quarkus transition and recent realm/client defaults may not be accounted for.

Key questions.

  • Which Laravel and PHP versions are actually supported, and does it install cleanly on our target?
  • Which OIDC flow does it implement, and does it validate state, nonce, and ID-token signature?
  • How are access/refresh tokens stored and refreshed, and what is the re-auth behavior on refresh failure?
  • Is there a supported RP-initiated logout, and does it clear the Laravel session correctly?
  • Can Keycloak realm/client roles and group claims be mapped to Laravel gates/policies without forking?
  • Who maintains it now — is there a live fork, and what is the license for a private fork?
  • Does it call the userinfo or introspection endpoint per request (a hot-path dependency on Keycloak)?

Integration Approach

Stack fit. Best fit: Laravel monolith, session driver backed by Redis or database, Keycloak as the sole IdP, roles expressed as Keycloak realm/client roles. Acceptable fit: Inertia or Livewire apps where the session cookie is the auth carrier. Poor fit: anything requiring per-request bearer-token validation, multi-IdP federation, or offline/CLI access.

Migration path. From a bespoke OIDC/SAML integration or Socialite, this is a guard swap behind the same route middleware — comparatively clean. From local Laravel auth, plan a transitional period with both guards active and account linking on a stable claim (sub preferred, email as fallback with a reconciliation job), then retire the local guard. Do not attempt a hard cutover; the user-identity mapping is where migrations fail.

Compatibility. Pin the Composer constraint to the exact Laravel minor we run, and verify the full dependency tree resolves. Given archived status, the realistic options are: (a) consume as-is with a pinned lockfile and an internal risk acceptance, (b) fork into our VCS namespace, apply framework/PHP compatibility patches and dependency bumps, and reference via a VCS repository entry, or (c) use it as a reference implementation and reimplement the guard in-house (~a few hundred lines). Option (b) is the default recommendation; (c) is worth costing if the package's protocol handling is thin.

Sequencing.

  1. Sandbox spike against a real Keycloak realm on our target Keycloak version; validate install, login, logout, refresh.
  2. Security review of token handling and claim validation; decide fork vs. reimplement.
  3. Fork and pin; add CI that runs the guard's tests against our framework matrix.
  4. Wire guard, provider, and route middleware in a non-production environment.
  5. Map realm/client roles to Laravel gates; add authorization tests.
  6. Instrument login/logout/refresh telemetry and error paths.
  7. Roll out behind a feature flag to an internal cohort, then broadly.
  8. Decommission the prior auth path and document the runbook.

Operational Impact

Maintenance. Assume full ownership of the code path from day one. Budget recurring effort for dependency and security patching, Keycloak upgrade compatibility testing, and OIDC protocol review — realistically a few days per quarter, plus a spike each time Keycloak or Laravel ships a major. The archived status converts a "free" dependency into a small internal product.

Support. No upstream maintainer, no SLA, no guaranteed responses on issues. Support is internal: a runbook covering redirect-URI misconfiguration, realm/client secret rotation, session invalidation, and Keycloak outage behavior. Ensure at least two engineers can operate it.

Scaling. The guard itself is cheap per request; scaling pressure lands elsewhere. Session storage becomes the constraint (size and TTL of token-bearing sessions), and login/refresh bursts concentrate load on Keycloak — so Keycloak needs its own HA posture and the app needs refresh jitter to avoid thundering herds at token expiry. If the package performs userinfo or introspection calls per request, model that as a synchronous dependency on the IdP's availability and latency budget.

Failure modes.

  • Keycloak unavailable → redirect loops or 5xx at the auth boundary; needs a fail-closed path with a clear error page.
  • Expired/rotated refresh token → forced re-authentication mid-session; UX must degrade gracefully.
  • Clock skew between app and IdP → intermittent token validation failures that are hard to reproduce.
  • Redirect-URI or client-secret misconfiguration → silent login loop, frequently misdiagnosed as an app bug.
  • Session store loss/eviction → mass logout event; size the store accordingly.
  • Archived dependency with an unpatched CVE → no upstream fix path; the fork is the mitigation.
  • Token material exposed via session compromise → scope tokens narrowly in Keycloak and keep session cookies HttpOnly/Secure/SameSite.

Ramp-up. One to two days for a Laravel developer to wire and configure; one to two weeks before the team is genuinely confident in OIDC edge cases (refresh, logout, claim mapping). Require at least one engineer with real OIDC/Keycloak depth — the package hides the happy path well but not the failure modes. Verdict: viable as a short-term accelerator for a session-based Laravel app already standardized on Keycloak, contingent on forking and owning it; not viable as a long-term unmodified dependency.

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.
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support