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

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

socialiteproviders/keycloak
===========================

Keycloak OAuth2 Provider for Laravel Socialite

5.3.0(3y ago)211.8M—2.1%1310MITPHPPHP ^7.4 || ^8.0

Since Apr 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/SocialiteProviders/Keycloak)[ Packagist](https://packagist.org/packages/socialiteproviders/keycloak)[ RSS](/packages/socialiteproviders-keycloak/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (11)Used By (10)

Keycloak
========

[](#keycloak)

```
composer require socialiteproviders/keycloak
```

Installation &amp; Basic Usage
------------------------------

[](#installation--basic-usage)

Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), then follow the provider specific instructions below.

### Add configuration to `config/services.php`

[](#add-configuration-to-configservicesphp)

```
'keycloak' => [
  'client_id' => env('KEYCLOAK_CLIENT_ID'),
  'client_secret' => env('KEYCLOAK_CLIENT_SECRET'),
  'redirect' => env('KEYCLOAK_REDIRECT_URI'),
  'base_url' => env('KEYCLOAK_BASE_URL'),   // Specify your keycloak server URL here
  'realms' => env('KEYCLOAK_REALM')         // Specify your keycloak realm
],
```

### Add provider event listener

[](#add-provider-event-listener)

#### Laravel 11+

[](#laravel-11)

In Laravel 11, the default `EventServiceProvider` provider was removed. Instead, add the listener using the `listen` method on the `Event` facade, in your `AppServiceProvider` `boot` method.

- Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.

```
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('keycloak', \SocialiteProviders\Keycloak\Provider::class);
});
```

Laravel 10 or below Configure the package's listener to listen for `SocialiteWasCalled` events. Add the event to your `listen[]` array in `app/Providers/EventServiceProvider`. See the [Base Installation Guide](https://socialiteproviders.com/usage/) for detailed instructions.

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\Keycloak\KeycloakExtendSocialite::class.'@handle',
    ],
];
```

### Usage

[](#usage)

You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

```
return Socialite::driver('keycloak')->redirect();
```

To logout of your app and Keycloak:

```
public function logout() {
    // Logout of your app.
    Auth::logout();

    // The user will not be redirected back.
    return redirect(Socialite::driver('keycloak')->getLogoutUrl());

    // The URL the user is redirected to after logout.
    $redirectUri = Config::get('app.url');

    // Keycloak v18+ does support a post_logout_redirect_uri in combination with a
    // client_id or an id_token_hint parameter or both of them.
    // NOTE: You will need to set valid post logout redirect URI in Keycloak.
    return redirect(Socialite::driver('keycloak')->getLogoutUrl($redirectUri, env('KEYCLOAK_CLIENT_ID')));
    return redirect(Socialite::driver('keycloak')->getLogoutUrl($redirectUri, null, 'YOUR_ID_TOKEN_HINT'));
    return redirect(Socialite::driver('keycloak')->getLogoutUrl($redirectUri, env('KEYCLOAK_CLIENT_ID'), 'YOUR_ID_TOKEN_HINT'));

    // You may add additional allowed parameters as listed in
    // https://openid.net/specs/openid-connect-rpinitiated-1_0.html
    return redirect(Socialite::driver('keycloak')->getLogoutUrl($redirectUri, CLIENT_ID, null, ['state' => '...'], ['ui_locales' => 'de-DE']));

    // Keycloak before v18 does support a redirect URL
    // to redirect back to Keycloak.
    return redirect(Socialite::driver('keycloak')->getLogoutUrl($redirectUri));
}
```

#### Keycloak &lt;= 3.2

[](#keycloak--32)

Keycloak below v3.2 requires no scopes to be set. Later versions require the `openid` scope for all requests.

```
return Socialite::driver('keycloak')->scopes([])->redirect();
```

See [the upgrade guide](https://www.keycloak.org/docs/12.0/upgrading/#migrating-to-3-2-0).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance56

Moderate activity, may be stable

Popularity52

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~119 days

Recently: every ~169 days

Total

10

Last Release

1135d ago

Major Versions

v3.0.2 → 4.0.02020-10-25

4.1.0 → 5.0.02021-06-02

PHP version history (4 changes)v3.0.0PHP ^5.6 || ^7.0

v3.0.2PHP ^7.2

4.1.0PHP ^7.2 || ^8.0

5.2.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/65eb3a7ba2a2c13b3a9de48b836caf759ad4052f9a839e30464c80d177d5b3d2?d=identicon)[atymic](/maintainers/atymic)

---

Top Contributors

[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (15 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (13 commits)")[![francipvb](https://avatars.githubusercontent.com/u/6855885?v=4)](https://github.com/francipvb "francipvb (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![maks-oleksyuk](https://avatars.githubusercontent.com/u/90793591?v=4)](https://github.com/maks-oleksyuk "maks-oleksyuk (1 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (1 commits)")[![robiiinos](https://avatars.githubusercontent.com/u/16455953?v=4)](https://github.com/robiiinos "robiiinos (1 commits)")[![robsontenorio](https://avatars.githubusercontent.com/u/118955?v=4)](https://github.com/robsontenorio "robsontenorio (1 commits)")[![sebastianmulders](https://avatars.githubusercontent.com/u/3605090?v=4)](https://github.com/sebastianmulders "sebastianmulders (1 commits)")[![vdeville](https://avatars.githubusercontent.com/u/6104498?v=4)](https://github.com/vdeville "vdeville (1 commits)")[![voenniy](https://avatars.githubusercontent.com/u/266377?v=4)](https://github.com/voenniy "voenniy (1 commits)")[![christophheich](https://avatars.githubusercontent.com/u/16765979?v=4)](https://github.com/christophheich "christophheich (1 commits)")

---

Tags

laraveloauthoauth1oauth2social-mediasocialitesocialite-providerslaravelprovideroauthsocialitekeycloak

### Embed Badge

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

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

###  Alternatives

[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[socialiteproviders/instagram

Instagram OAuth2 Provider for Laravel Socialite

421.9M5](/packages/socialiteproviders-instagram)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

2073.7k](/packages/kovah-laravel-socialite-oidc)[socialiteproviders/kakao

Kakao OAuth2 Provider for Laravel Socialite

10484.7k4](/packages/socialiteproviders-kakao)

PHPackages © 2026

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