PHPackages                             tadasei/laravel-keycloak-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. tadasei/laravel-keycloak-guard

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

tadasei/laravel-keycloak-guard
==============================

My fork of leandrose/laravel-keycloak-guard.

v1.0.0(1mo ago)02↓50%MITPHPPHP ^8.2

Since Jun 12Pushed 1mo agoCompare

[ Source](https://github.com/Tadasei/laravel-keycloak-guard)[ Packagist](https://packagist.org/packages/tadasei/laravel-keycloak-guard)[ Docs](https://github.com/leandrose/laravel-keycloak-guard)[ RSS](/packages/tadasei-laravel-keycloak-guard/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Laravel Keycloak Guard
======================

[](#laravel-keycloak-guard)

A lightweight **Laravel authentication guard** for applications acting as **OAuth2 / OpenID Connect resource servers using Keycloak**.

This package validates **Bearer tokens issued by Keycloak** by first verifying the JWT signature locally with the realm public key and then confirming the token through the **token introspection endpoint**.

It also provides **optional caching of introspection responses** to reduce load on the Keycloak server and improve API performance.

---

Features
--------

[](#features)

- Stateless **Bearer Token authentication**
- **Keycloak OAuth2 / OpenID Connect** integration
- Token validation via **local JWT verification** plus **introspection endpoint**
- Optional **introspection caching**
- Cache TTL automatically respecting token expiration (`exp`)
- Custom Laravel **Guard**
- Works with **Laravel 10, 11, 12 and 13**

---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10 / 11 / 12 / 13
- Keycloak server with OAuth2 / OpenID Connect enabled
- Keycloak realm public key available to the application

Version Compatibility
---------------------

[](#version-compatibility)

Package VersionLaravel 10Laravel 11Laravel 12Laravel 13`v1.0`✅✅✅✅---

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require leandrose/laravel-keycloak-guard
```

Publish the configuration file:

```
php artisan vendor:publish --provider="LeandroSe\\KeycloakGuard\\KeycloakAuthServiceProvider"
```

Add this to the `guards` array in `config/auth.php`:

```
'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],
'guards' => [
    'keycloak' => [
        'driver' => 'keycloak',
        'provider' => 'users',
    ],
],
```

Configure the Keycloak connection in your environment:

```
KEYCLOAK_BASE_URL=https://keycloak.example.com
KEYCLOAK_REALM=your-realm
KEYCLOAK_CLIENT_ID=your-client-id
KEYCLOAK_CLIENT_SECRET=your-client-secret
KEYCLOAK_REALM_PUBLIC_KEY="..."
```

`KEYCLOAK_REALM_PUBLIC_KEY` can be provided either as a full PEM or as the raw base64 body of the public key.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f56b423b676a1de482a2c09129ce3bfd92a62fdad2dedbed6d9837c3fe7f81d?d=identicon)[Tadasei](/maintainers/Tadasei)

---

Top Contributors

[![leandrose](https://avatars.githubusercontent.com/u/545876?v=4)](https://github.com/leandrose "leandrose (3 commits)")[![Tadasei](https://avatars.githubusercontent.com/u/93480860?v=4)](https://github.com/Tadasei "Tadasei (3 commits)")

---

Tags

laravelAuthenticationoauth2OpenID Connectkeycloakguardresource serverbearer token

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tadasei-laravel-keycloak-guard/health.svg)

```
[![Health](https://phpackages.com/badges/tadasei-laravel-keycloak-guard/health.svg)](https://phpackages.com/packages/tadasei-laravel-keycloak-guard)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M134](/packages/roots-acorn)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M927](/packages/laravel-socialite)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M137](/packages/laravel-pulse)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M348](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
