jurager/passport

Laravel package to implement single sign-on method

1.6.4 2025-02-14 04:52 UTC

This package is auto-updated.

Last update: 2025-09-24 05:25:01 UTC


README

Latest Stable Version Total Downloads PHP Version Require License

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.