PHPackages                             alterindonesia/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. alterindonesia/keycloak-guard

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

alterindonesia/keycloak-guard
=============================

Keycloak Guard for Laravel

v1.0.0(9mo ago)0111MITPHPPHP ^8.0

Since Apr 1Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/febrianrz/keycloak-guard)[ Packagist](https://packagist.org/packages/alterindonesia/keycloak-guard)[ RSS](/packages/alterindonesia-keycloak-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Keycloak Guard Packages
=======================

[](#keycloak-guard-packages)

This package is a guard for keycloak. This package is a fork from [keycloak-guard](https://github.com/robsontenorio/laravel-keycloak-guard) package and change several code.

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

[](#installation)

```
composer require alterindonesia/keycloak-guard
```

Environment
-----------

[](#environment)

```
KEYCLOAK_REALM_PUBLIC_KEY=
KEYCLOAK_LOAD_USER_FROM_DATABASE=false
KEYCLOAK_USER_PROVIDER_CREDENTIAL=email
KEYCLOAK_TOKEN_PRINCIPAL_ATTRIBUTE=preferred_username
KEYCLOAK_APPEND_DECODED_TOKEN=true
KEYCLOAK_ALLOWED_RESOURCES=account
KEYCLOAK_IGNORE_RESOURCES_VALIDATION=false
KEYCLOAK_LEEWAY=0
KEYCLOAK_TOKEN_INPUT_KEY=null
KEYCLOAK_SESSION_SYNC=true
KEYCLOAK_URL=
KEYCLOAK_REALM=
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="Alterindonesia\KeycloakGuard\KeycloakGuardServiceProvider"
```

Usage
-----

[](#usage)

There are two ways to use this package:

1. Just decode the token and get the user data from the token.
2. Sync the user data from the token on keycloak server API.

```
KEYCLOAK_SESSION_SYNC=true
KEYCLOAK_URL=
KEYCLOAK_REALM=
```

### Laravel Auth

[](#laravel-auth)

Changes on config/auth.php

```
    ...
    'defaults' => [
        'guard' => 'api', #  'users',
    ],

    ....

    'guards' => [
        #
        'api' => [
            'driver' => 'keycloak',
            'provider' => 'users',
        ],
    ],
```

### Laravel Routes

[](#laravel-routes)

```
// protected endpoints
Route::group(['middleware' => 'auth:api'], function () {
    Route::get('/protected-endpoint', 'SecretController@index');
    // more endpoints ...
});
```

Big Thanks
----------

[](#big-thanks)

- [robsontenorio](https://github.com/robsontenorio) for the original package.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance58

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~99 days

Recently: every ~123 days

Total

6

Last Release

276d ago

Major Versions

v0.0.5 → v1.0.02025-08-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/79719558f26d9ee58a9c136ab15a2d15b3f1154b42ac6ff2545a69a65d363fd2?d=identicon)[febrianrz1](/maintainers/febrianrz1)

---

Top Contributors

[![transgen](https://avatars.githubusercontent.com/u/12225260?v=4)](https://github.com/transgen "transgen (4 commits)")

### Embed Badge

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

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5161.1M3](/packages/robsontenorio-laravel-keycloak-guard)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[wp-graphql/wp-graphql-jwt-authentication

JWT Authentication for WPGraphQL

361118.4k1](/packages/wp-graphql-wp-graphql-jwt-authentication)

PHPackages © 2026

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