PHPackages                             laravel-auto/sso - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. laravel-auto/sso

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

laravel-auto/sso
================

Simple PHP SSO integration for Laravel

04PHP

Since Aug 3Pushed 9mo agoCompare

[ Source](https://github.com/chareka-legacy/laravel-sso)[ Packagist](https://packagist.org/packages/laravel-auto/sso)[ RSS](/packages/laravel-auto-sso/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Simple PHP SSO integration for Laravel
======================================

[](#simple-php-sso-integration-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/5783065037e227ce3910c3925870ab1fd3c7eb48f1b98236934b019812e8d835/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6175746f2f73736f2f762f737461626c65)](https://packagist.org/packages/laravel-auto/sso)[![Total Downloads](https://camo.githubusercontent.com/66ec96516ef1f919f3a65e7bed9bb556975c437d0a52db01bf1a0c5664471fb7/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6175746f2f73736f2f646f776e6c6f616473)](https://packagist.org/packages/laravel-auto/sso)[![Latest Unstable Version](https://camo.githubusercontent.com/5c70877261da16388ae564d3ef6cfa695e5449b31ee841085ef61d2fc5ad7fd2/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6175746f2f73736f2f762f756e737461626c65)](https://packagist.org/packages/laravel-auto/sso)[![License](https://camo.githubusercontent.com/d8b57ce4aecbff4fbd3428b5a2cc17bebe698aebb8590fc3d8d739e7763eee14/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d6175746f2f73736f2f6c6963656e7365)](https://packagist.org/packages/laravel-auto/sso)

This package based on [Simple PHP SSO skeleton](https://github.com/zefy/php-simple-sso) package and made suitable for Laravel framework.

### Requirements

[](#requirements)

- Laravel 10.0+
- PHP 7.4+

### Words meanings

[](#words-meanings)

- ***SSO*** - Single Sign-On.
- ***Server*** - page which works as SSO server, handles authentications, stores all sessions data.
- ***Broker*** - your page which is used visited by clients/users.
- ***Client/User*** - your every visitor.

### How it works?

[](#how-it-works)

Client visits Broker and unique token is generated. When new token is generated we need to attach Client session to his session in Broker so he will be redirected to Server and back to Broker at this moment new session in Server will be created and associated with Client session in Broker's page. When Client visits other Broker same steps will be done except that when Client will be redirected to Server he already use his old session and same session id which associated with Broker#1.

Installation
============

[](#installation)

### Server

[](#server)

Install this package using composer.

```
$ composer require laravel-auto/sso
```

Copy config file to Laravel project `config/` folder.

```
$ php artisan vendor:publish --provider="LaravelAuto\Sso\SingleSignOnServiceProvider"
```

Create table where all brokers will be saved.

```
$ php artisan migrate --path=vendor/laravel-auto/sso/database/migrations
```

Edit your `app/Http/Kernel.php` by removing throttle middleware and adding sessions middleware to `api` middlewares array. This is necessary because we need sessions to work in API routes and throttle middleware can block connections which we need.

```
'api' => [
    'bindings',
    \Illuminate\Session\Middleware\StartSession::class,
],
```

Now you should create brokers. You can create new broker using following Artisan CLI command:

```
$ php artisan sso:broker:create {name}
```

---

### Broker

[](#broker)

Install this package using composer.

```
$ composer require laravel-auto/sso
```

Copy config file to Laravel project `config/` folder.

```
$ php artisan vendor:publish --provider="LaravelAuto\Sso\SingleSignOnServiceProvider"
```

Change `type` value in `config/laravel-sso.php` file from `server`to `broker`.

Set 3 new options in your `.env` file:

```
SSO_SERVER_URL=
SSO_BROKER_NAME=
SSO_BROKER_SECRET=
```

`SSO_SERVER_URL` is your server's http url without trailing slash. `SSO_BROKER_NAME` and `SSO_BROKER_SECRET` must be data which exists in your server's `brokers` table.

Edit your `app/Http/Kernel.php` by adding `\LaravelAuto\Sso\Middleware\SingleSignOnVerification::class` middleware to `web` middleware group. It should look like this:

```
protected $middlewareGroups = [
        'web' => [
            ...
            \LaravelAuto\Sso\Middleware\SingleSignOnVerification::class,
        ],

        'api' => [
            ...
        ],
    ];
```

Last but not least, you need to edit `app/Http/Controllers/Auth/LoginController.php`. You should add two functions into `LoginController` class which will authenticate your client through SSO server but not your Broker page.

```
protected function attemptLogin(Request $request)
{
    $broker = new \LaravelAuto\Sso\SingleSignOnBroker;

    $credentials = $this->credentials($request);
    return $broker->login($credentials[$this->username()], $credentials['password']);
}

public function logout(Request $request)
{
    $broker = new \LaravelAuto\Sso\SingleSignOnBroker;

    $broker->logout();

    $this->guard()->logout();

    $request->session()->invalidate();

    return redirect('/');
}
```

That's all. For other Broker pages you should repeat everything from the beginning just changing your Broker name and secret in configuration file.

Example `.env` options:

```
SSO_SERVER_URL=https://server.test
SSO_BROKER_NAME=site1
SSO_BROKER_SECRET=892asjdajsdksja74jh38kljk2929023
```

### Usage Options

[](#usage-options)

#### User creating/fetching mapping

[](#user-creatingfetching-mapping)

When mapping user creation use inside `config/laravel-sso.php`:

```
    // Logged in user fields sent to brokers.
    'userFields' => [
        // Return array field name => database column name
        'id' => 'id',
        'name' => 'name',
        'email' => 'email',
    ],
```

And if broker uses different names for user fields:

```
// probably in your service provider
\LaravelAuto\Sso\Middleware\SingleSignOnVerification::createOrFindUserUsing(function (array $data){
    return User::firstOrCreate([
        'name_on_broker' => $data['name_from_server']
    ]);
});
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance43

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e270292643f0d9a467ac1010400d65143f8104b15eaafc4bdbb29d16efaa12d6?d=identicon)[joechark](/maintainers/joechark)

---

Top Contributors

[![martynaszaliaduonis](https://avatars.githubusercontent.com/u/43949022?v=4)](https://github.com/martynaszaliaduonis "martynaszaliaduonis (24 commits)")[![zefy](https://avatars.githubusercontent.com/u/5538557?v=4)](https://github.com/zefy "zefy (12 commits)")[![jcharika](https://avatars.githubusercontent.com/u/42941541?v=4)](https://github.com/jcharika "jcharika (10 commits)")

### Embed Badge

![Health badge](/badges/laravel-auto-sso/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-auto-sso/health.svg)](https://phpackages.com/packages/laravel-auto-sso)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
