omniglies / laravel-sso-client
Laravel package for OAuth client using Laravel Socialite with LaravelPassport driver
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/omniglies/laravel-sso-client
Requires
- php: ^8.2
 - illuminate/support: ^12.0
 - laravel/socialite: ^5.0
 - socialiteproviders/laravelpassport: ^4.0
 
Requires (Dev)
- orchestra/testbench: ^10.0
 - phpunit/phpunit: ^11.5|^12.0
 
- dev-main
 - v12.0.10
 - v12.0.9
 - v12.0.8
 - v12.0.7
 - v12.0.6
 - v12.0.5
 - v12.0.4
 - v12.0.3
 - v12.0.2
 - v12.0.1
 - v12.0.0
 - 11.x-dev
 - v11.0.12
 - v11.0.11
 - v11.0.10
 - v11.0.8
 - v11.0.7
 - v11.0.6
 - v11.0.5
 - v11.0.4
 - v11.0.3
 - v11.0.2
 - v11.0.1
 - v11.0.0
 - 10.x-dev
 - v10.0.12
 - v10.0.11
 - v10.0.10
 - v10.0.8
 - v10.0.7
 - v10.0.6
 - v10.0.5
 - v10.0.4
 - v10.0.3
 - v10.0.2
 - v10.0.1
 - v10.0.0
 - 9.x-dev
 - v9.0.16
 - v9.0.15
 - v9.0.14
 - v9.0.13
 - v9.0.12
 - v9.0.11
 - v9.0.10
 - v9.0.9
 - v9.0.8
 - v9.0.7
 - v9.0.6
 - v9.0.5
 - v9.0.4
 - v9.0.3
 - v9.0.2
 - v9.0.1
 - v9.0.0
 
This package is auto-updated.
Last update: 2025-10-28 11:54:11 UTC
README
A Laravel package for OAuth client implementation using Laravel Socialite with LaravelPassport driver.
Features
- Easy SSO integration with LaravelPassport OAuth server
 - Automatic user synchronization from OAuth server
 - Configurable user model and field preservation
 - Support for Spatie Laravel Permission roles
 - Artisan command for easy installation and setup
 - Local and SSO logout options
 
Version Compatibility
| Laravel Version | Package Version | PHP Version | Branch | Status | 
|---|---|---|---|---|
| 12.x | ^12.0 | ^8.2 | main | Active Development | 
| 11.x | ^11.0 | ^8.2 | 11.x | Active Maintenance | 
| 10.x | ^10.0 | ^8.1 | 10.x | Active Maintenance | 
| 9.x | ^9.0 | ^8.0 | 9.x | LTS / Security Fixes | 
Installation
Via Composer
Laravel 12.x (Latest)
composer require omniglies/laravel-sso-client
Laravel 11.x
composer require omniglies/laravel-sso-client:^11.0
Laravel 10.x
composer require omniglies/laravel-sso-client:^10.0
Laravel 9.x
composer require omniglies/laravel-sso-client:^9.0
Quick Setup
Run the installation command to automatically configure everything:
php artisan sso:install
This command will:
- Publish configuration files
 - Publish database migrations
 - Configure required services
 - Update EventServiceProvider
 - Add environment variables template
 
Manual Installation
- Publish the configuration:
 
php artisan vendor:publish --tag=sso-client-config
- Publish migrations:
 
php artisan vendor:publish --tag=sso-client-migrations
- Run migrations:
 
php artisan migrate
- Add to your 
.envfile: 
LARAVELPASSPORT_CLIENT_ID=your_client_id LARAVELPASSPORT_CLIENT_SECRET=your_client_secret LARAVELPASSPORT_REDIRECT_URI=http://your-app.com/sso/callback LARAVELPASSPORT_HOST=http://your-oauth-server.com
Configuration
config/sso-client.php
return [ // User model to use for authentication 'user_model' => 'App\\Models\\User', // Default role for new SSO users (requires Spatie Permission) 'default_role' => null, // Fields that won't be overwritten during sync 'preserved_fields' => [ 'id_role', 'nik', 'address', 'nip_pbb', 'kd_propinsi', 'kd_dati2', 'kd_kecamatan', 'kd_kelurahan' ], // Redirect path after successful login 'redirect_after_login' => '/home', // Route configuration 'route_prefix' => 'sso', 'middleware' => ['web'], ];
Usage
Routes
The package automatically registers these routes:
GET /sso/redirect- Redirect to OAuth serverGET /sso/callback- OAuth callback handlerPOST /sso/logout- SSO logout (logs out from both local and OAuth server)POST /sso/local-logout- Local logout only
In your views
{{-- SSO Login Button --}} <a href="{{ route('sso.redirect') }}" class="btn btn-primary"> Login with SSO </a> {{-- SSO Logout Button --}} <form method="POST" action="{{ route('sso.logout') }}"> @csrf <button type="submit" class="btn btn-secondary"> Logout (SSO) </button> </form> {{-- Local Logout Only --}} <form method="POST" action="{{ route('sso.local-logout') }}"> @csrf <button type="submit" class="btn btn-secondary"> Logout (Local Only) </button> </form>
User Service
Access the SSO user service for advanced operations:
use Omniglies\LaravelSsoClient\Services\SsoUserService; $ssoService = new SsoUserService(); // Search users (requires admin token) $users = $ssoService->withToken($adminToken)->searchUsers(['email' => 'user@example.com']); // Create user on OAuth server $newUser = $ssoService->withToken($adminToken)->createUser([ 'name' => 'John Doe', 'email' => 'john@example.com', 'username' => 'johndoe', 'password' => 'password' ]); // Sync local user with OAuth server $ssoService->syncLocalUser($user);
Database Schema
The package adds these fields to your users table:
oauth_id- Unique OAuth user IDusername- Username from OAuth serveroauth_data- JSON field storing all OAuth user datasynced_at- Last sync timestampis_active- User active status
Requirements
This package supports multiple Laravel versions with different requirements:
Laravel 12.x (main branch)
- PHP ^8.2
 - Laravel ^12.0
 - Laravel Socialite ^5.0
 - SocialiteProviders LaravelPassport ^4.0
 
Laravel 11.x (11.x branch)
- PHP ^8.2
 - Laravel ^11.0
 - Laravel Socialite ^5.0
 - SocialiteProviders LaravelPassport ^4.0
 
Laravel 10.x (10.x branch)
- PHP ^8.1
 - Laravel ^10.0
 - Laravel Socialite ^5.0
 - SocialiteProviders LaravelPassport ^4.0
 
Laravel 9.x (9.x branch)
- PHP ^8.0
 - Laravel ^9.0
 - Laravel Socialite ^5.0
 - SocialiteProviders LaravelPassport ^4.0
 
License
MIT License