PHPackages                             toniel/laravel-keycloak-socialite - 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. toniel/laravel-keycloak-socialite

ActiveLibrary

toniel/laravel-keycloak-socialite
=================================

Reusable Keycloak Socialite authentication for Laravel applications.

v1.2.0(1mo ago)03MITPHPPHP ^8.2

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/toniel/laravel-keycloak-socialite)[ Packagist](https://packagist.org/packages/toniel/laravel-keycloak-socialite)[ RSS](/packages/toniel-laravel-keycloak-socialite/feed)WikiDiscussions main Synced 1w ago

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

Laravel Keycloak Socialite
==========================

[](#laravel-keycloak-socialite)

Reusable Keycloak Socialite authentication for Laravel applications. Provides a drop-in Keycloak SSO integration with redirect, callback, logout, and **backchannel logout** routes — configurable and decoupled from any specific User model or permission system.

Features
--------

[](#features)

- **SSO Login** — Redirect to Keycloak, callback with auto-register
- **Silent Logout** — Logout from Keycloak without confirmation page (via `id_token_hint`)
- **Backchannel Logout** — When user logs out from any app, all other apps in the ecosystem are logged out automatically
- **Cross-app SSO** — Login once, access all apps in the same Keycloak realm
- **Configurable IDP Hint** — Skip Keycloak login screen, go directly to Google/GitHub/etc
- **Event-driven** — Hook into login, registration, and failure events

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

[](#requirements)

- PHP 8.2+
- Laravel 12+ / 13+
- A running [Keycloak](https://www.keycloak.org/) server (tested with v26+)

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

[](#installation)

```
composer require toniel/laravel-keycloak-socialite
```

Publish the configuration file:

```
php artisan vendor:publish --tag=keycloak-socialite-config
```

Publish the migration (optional — only if your users table doesn't already have the columns):

```
php artisan vendor:publish --tag=keycloak-socialite-migrations
php artisan migrate
```

Environment Variables
---------------------

[](#environment-variables)

Add these to your `.env` file:

```
KEYCLOAK_BASE_URL=https://auth.example.com
KEYCLOAK_REALM=your-realm
KEYCLOAK_CLIENT_ID=your-client-id
KEYCLOAK_CLIENT_SECRET=your-client-secret
KEYCLOAK_REDIRECT_URI=http://your-app.test/auth/keycloak/callback

# Optional
KEYCLOAK_IDP_HINT=google              # Skip Keycloak login screen, go directly to an IDP
KEYCLOAK_AUTO_REGISTER=true           # Create users automatically on first login
KEYCLOAK_REMEMBER_LOGIN=false         # Disable for SSO — let Keycloak manage session
KEYCLOAK_REDIRECT_URL=/dashboard      # Fallback post-login redirect

# Logout
KEYCLOAK_LOGOUT_MODE=keycloak         # 'keycloak' (destroy SSO session) or 'local' (app only)
KEYCLOAK_LOGOUT_REDIRECT=/            # Where to redirect after logout (must be registered in Keycloak)
KEYCLOAK_BACKCHANNEL_LOGOUT=true      # Enable backchannel logout endpoint
```

Setup Your User Model
---------------------

[](#setup-your-user-model)

Your User model must implement `KeycloakAuthenticatable`. Use the included trait for defaults:

```
