sobiz / laravel-sso
Single Sign-On package for Sobiz applications using OAuth 2.0 + OIDC
Requires
- php: ^8.1
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-03-16 13:57:15 UTC
README
A lightweight Single Sign-On (SSO) package for Laravel applications, enabling seamless authentication with Sobiz MyProfile (OAuth 2.0 + OIDC).
Features
- Easy installation and configuration.
- Seamless integration with Sobiz SSO server.
- Built-in middleware for protecting routes.
- Pre-configured login buttons and views.
- Clean uninstallation process.
Requirements
- PHP ^8.1
- Laravel ^10.0 or ^11.0
Installation
1. Install the package via composer
composer require sobiz/laravel-sso
2. Run the installation command
The installation command will publish the configuration file, migrations, and views. It will also add the necessary environment variables to your .env file.
php artisan sso:install
3. Register your application
Go to Sobiz MyProfile Admin and register your application to get your Client ID and Client Secret.
4. Update your .env file
Ensure the following variables are correctly set in your .env file:
SSO_AUTH_SERVER_URL=https://myprofile.sobiz.com SSO_CLIENT_ID=your-client-id SSO_CLIENT_SECRET=your-client-secret SSO_REDIRECT_URI=https://your-app.com/auth/sso/callback SSO_SESSION_DOMAIN=your-app-domain.com
Usage
Middleware
Protect your routes using the sso.auth middleware:
Route::middleware(['sso.auth'])->group(function () { Route::get('/dashboard', [DashboardController::class, 'index']); });
Login Button
Add the pre-styled SSO login button to your login page:
@include('sso::login-button')
SSO Facade
You can use the SSO facade to access user information or handle logout:
use Sobiz\LaravelSSO\Facades\SSO; // Get the authenticated SSO user $user = SSO::user(); // Logout SSO::logout();
Uninstallation
To remove the package resources (config, views, migrations, and environment variables) from your application, run:
php artisan sso:uninstall
Warning
This command will delete published files and remove SSO variables from your .env. If you have already run migrations, remember to roll them back manually before running this command if you wish to remove the database tables.
After running the uninstall command, you can remove the package from composer:
composer remove sobiz/laravel-sso
Troubleshooting
- Invalid state parameter: Ensure that your
SESSION_DOMAINin.envmatches the domain you are visiting, and that yourAPP_URLmatches your actual serving URL (including port if on localhost). - Redirection loop: Check if the
SSO_REDIRECT_URIis correctly registered in both your application.envand the MyProfile admin portal.
License
The MIT License (MIT). Please see License File for more information.