robsontenorio/laravel-keycloak-guard
Laravel Keycloak Guard provides a Keycloak authentication guard for Laravel, validating JWT access tokens and exposing roles and permissions. It integrates with Laravel's native auth system, making it easy to protect routes and APIs with Keycloak-issued tokens.
laravel-keycloak-guard lets a Laravel app delegate authentication to an existing Keycloak realm instead of building OIDC/SAML integration and token validation in-house. This is a buy/borrow decision that trades control for speed — relevant whenever an enterprise customer or internal IT standardizes on Keycloak.id() so it supports string/UUID identifiers instead of assuming integer-like IDs. Product implication: Keycloak realms configured with UUID user IDs (the default in many modern realms) previously broke or misbehaved on login. If any target account uses default Keycloak realm settings, 2.0.0 was effectively unusable and 2.0.1 is the first viable version. Any pilot planned on 2.0.0 should be re-baselined to 2.0.1 before you draw conclusions about fit.Consider it when:
Look elsewhere when:
For executives: This is a small, focused library that lets our Laravel application accept logins from a customer's existing Keycloak identity system. The commercial case is deal enablement: enterprise and public-sector buyers frequently mandate their own identity provider, and "we support Keycloak SSO" removes a common procurement blocker without us building and securing an SSO stack ourselves. The 2.0.1 release fixes a real defect — logins failed for Keycloak realms using UUID user identifiers, which is the default in modern setups — so it materially widens the set of customers we can actually serve. The trade-off is dependency risk: it is community-maintained, so we should pin the version, track releases, and treat SSO as "supported" only once we have a tested integration and a fallback plan.
For engineering: Adopt at a pinned 2.0.1 (not 2.0.0 — its id() assumed integer-like identifiers and breaks on UUID subjects). Scope is guard-level authentication against Keycloak tokens with role/claim access through Laravel's auth layer, so we get token validation and role mapping without hand-rolling JWKS handling and key rotation. Action items: run a spike against our actual Keycloak realm configuration (UUID vs. legacy IDs), confirm Laravel/PHP version compatibility, add integration tests around login and role checks so future upstream patches are cheap to evaluate, and add a dependency-review step to our upgrade cadence given the rapid 2.0.0 → 2.0.1 follow-up. If we need multi-IdP, per-tenant MFA policy, or a supported vendor contract, this package is the wrong layer and we should revisit the architecture rather than extend it.
How can I help you explore Laravel packages today?