jurager / passport
Laravel package to implement single sign-on method
Requires
- php: ^8.1
- ext-json: *
- ext-pdo: *
- guzzlehttp/guzzle: ^6.0|^7.0
- guzzlehttp/psr7: ^2.4.5
- illuminate/auth: ^9.0|^10.0|^11.0|^12.0
- illuminate/collections: ^9.0|^10.0|^11.0|^12.0
- illuminate/config: ^9.0|^10.0|^11.0|^12.0
- illuminate/console: ^9.0|^10.0|^11.0|^12.0
- illuminate/contracts: ^9.0|^10.0|^11.0|^12.0
- illuminate/cookie: ^9.0|^10.0|^11.0|^12.0
- illuminate/database: ^9.0|^10.0|^11.0|^12.0
- illuminate/http: ^9.0|^10.0|^11.0|^12.0
- illuminate/macroable: ^9.0|^10.0|^11.0|^12.0
- illuminate/queue: ^9.0|^10.0|^11.0|^12.0
- illuminate/routing: ^9.0|^10.0|^11.0|^12.0
- illuminate/session: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
- symfony/http-foundation: ^5.0|^6.0|^7.0
README
This Laravel package simplifies the implementation of single sign-on authentication. It features a centralized user repository and enables the creation of user models in brokers without disrupting app logic. Additionally, it provides methods for incorporating authentication history pages and terminating sessions for either all users or specific ones with ease
Note
The documentation for this package is currently being written. For now, please refer to this readme for information on the functionality and usage of the package.
Requirements
PHP >= 8.1
and Laravel 9.x or higher
Installation
composer require jurager/passport
Run migrations:
php artisan migrate
Register the middleware:
Laravel 12 and newer
In Laravel 12, middleware is registered in `bootstrap/app.php` using the `withMiddleware` method.
<?php use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', // ... ) ->withMiddleware(static function (Middleware $middleware): void { // Prepend session start and broker attach to the 'web' group $middleware->web(prepend: [ \Illuminate\Session\Middleware\StartSession::class, \Jurager\Passport\Http\Middleware\AttachBroker::class ]); // Replace the default auth alias with package's version $middleware->alias([ 'auth' => \Jurager\Passport\Http\Middleware\ClientAuthenticate::class, ]); }) ->withExceptions(function ($exceptions) { // ... });
Laravel 11 and earlier
If your application still uses the classic HTTP kernel `app/Http/Kernel.php`, register middleware there.
Add middleware to the web
group:
protected $middlewareGroups = [ 'web' => [ \Illuminate\Session\Middleware\StartSession::class, \Jurager\Passport\Http\Middleware\AttachBroker::class, // ... ], ];
Replace the auth
middleware alias with the package's version:
protected $routeMiddleware = [ 'auth' => \Jurager\Passport\Http\Middleware\ClientAuthenticate::class, // ... ];
License
This package is open-sourced software licensed under the MIT license.