PHPackages                             maicol07/laravel-oidc-client - 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. maicol07/laravel-oidc-client

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

maicol07/laravel-oidc-client
============================

OpenID Connect Client for Laravel

1.1.1(6mo ago)251.1k↓50%13MITPHPPHP &gt;=8.3

Since Sep 29Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/maicol07/laravel-oidc-client)[ Packagist](https://packagist.org/packages/maicol07/laravel-oidc-client)[ Fund](https://paypal.me/maicol072001/10eur)[ GitHub Sponsors](https://github.com/maicol07)[ RSS](/packages/maicol07-laravel-oidc-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

OIDC Client
===========

[](#oidc-client)

A Laravel package for delegating authentication to an OpenID Provider.

> This package is an heavenly modified fork of [cabinetoffice / oidc-client — Bitbucket](https://bitbucket.org/cabinetoffice/oidc-client)

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11+
- Composer 2

Installation
------------

[](#installation)

Begin by adding this package to your depedencies with the command:

```
composer require maicol07/laravel-oidc-client
```

If you have opted out from auto discovery, you'll need to add the following line to the list of registered service providers in `config/app.php`:

```
Maicol07\OIDCClient\OIDCServiceProvider::class
```

Edit your `config/auth.php` file to use OpenID as the authentication method for your users:

```
'guards' => [
    'web' => [
        'driver' => 'oidc',
        ...
    ],
    ...
],
```

Configuration
-------------

[](#configuration)

You can set the following environment variables to adjust the package settings:

- `OIDC_CLIENT_ID`: Client ID of your app. This is commonly provided by your OIDC provider.
- `OIDC_CLIENT_SECRET`: Client secret of your app. This is commonly provided by your OIDC provider.
- `OIDC_PROVIDER_URL`: URL of your OIDC provider. This is used if your provider supports OIDC Auto Discovery.
- `OIDC_CALLBACK_ROUTE`: A path (with or without leading slash) to append to the provider name, to make the callback route path. Defaults to `callback`Example with the default values: `oidc/callback` (`oidc/` + `OIDC_CALLBACK_ROUTE_PATH`)
- `OIDC_VERIFY`: Verify SSL when sending requests to the server. Defaults to `true`. (Optional: You can set `OIDC_CERT_PATH` to an SSL certificate path if you set this option to `false`)
- `OIDC_HTTP_PROXY`: If you have a proxy, set it here.
- `OIDC_SCOPES`: A list of scopes, separated by a space (` `). Defaults to `['openid']`. Example of valid value: `openid email`
- `OIDC_AUTHORIZATION_ENDPOINT_QUERY_PARAMS`: A list of query parameters to add to the authorization endpoint encoded as a JSON object. Example of valid value: `{"response_type":"code"}`
- `OIDC_DISABLE_STATE_MIDDLEWARE_FOR_POST_CALLBACK`: A boolean to disable the registration of the `OIDCStateMiddleware` middleware.
    This middleware rebuilds the session token held in the `state` parameter of a `POST` request to the `callback` route.

You can find other options to set and their env variables in `config/oidc.php`. Note that some options are not required (like endpoints) if you use OIDC auto discovery!

You can also publish the config file (`config/oidc.php`) if you want:

```
php artisan vendor:publish --provider="Maicol07\OIDCClient\OIDCServiceProvider"
```

How to use
----------

[](#how-to-use)

Once everything is set up, you can replace your login system with a call to the route `route('oidc.login')`. For logouts, use the route `route('oidc.logout')`.

You can set the following environment variables to specify the routes/URLs you want your users to be redirected to upon successful authentication/logout: `OIDC_REDIRECT_PATH_AFTER_LOGIN` and `OIDC_REDIRECT_PATH_AFTER_LOGOUT`.

You should add the `Maicol07\OIDCClient\Models\Traits\LogsInWithOidc` to your `User` model if you want to use the get the mapping relation.

### Customizing user mappings

[](#customizing-user-mappings)

You can customize how the user information received from the OIDC provider is mapped to your `User` model by overriding the `mapOIDCUserinfo` method from the `LogsInWithOidc` trait in your `User` model. Here's an example of how to do this:

```
use Maicol07\OIDCClient\Models\Traits\LogsInWithOidc;
use Maicol07\OIDCClient\Models\OIDCUserinfo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, LogsInWithOidc;

    // Other model properties and methods...

    /**
     * Map OIDC UserInfo attributes to User model attributes.
     *
     * This method can be overridden in the User model to customize the mapping.
     *
     * @param string $issuer The OIDC issuer.
     * @param UserInfo $user_info The OIDC UserInfo object.
     * @param OidcAuthMapping $mapping The OIDC Auth Mapping instance.
     */
    public function mapOIDCUserinfo(string $issuer, UserInfo $user_info, OidcAuthMapping $mapping): void
    {
        // Custom mapping logic here
        $this->name = $user_info->get('name', $this->name);
        $this->email = $user_info->get('email', $this->email);
        // Add more mappings as needed
    }
}
```

---

> Originally developed by Cabinet Office Digital Development in October 2019.
>
> Currently maintained by [maicol07](https://maicol07.it) from October 2021

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance68

Regular maintenance activity

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.5% 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.

###  Release Activity

Cadence

Every ~19 days

Total

3

Last Release

187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6cf3779f6b891b03274b9477410134fc585a7dfba6de85ee720fa7e155f92d79?d=identicon)[maicol07](/maintainers/maicol07)

---

Top Contributors

[![maicol07](https://avatars.githubusercontent.com/u/9463142?v=4)](https://github.com/maicol07 "maicol07 (64 commits)")[![eviweb](https://avatars.githubusercontent.com/u/1310382?v=4)](https://github.com/eviweb "eviweb (10 commits)")

---

Tags

laravelAuthenticationSSOoauth2OpenIdoidc

###  Code Quality

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/maicol07-laravel-oidc-client/health.svg)

```
[![Health](https://phpackages.com/badges/maicol07-laravel-oidc-client/health.svg)](https://phpackages.com/packages/maicol07-laravel-oidc-client)
```

###  Alternatives

[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

55342.3k2](/packages/jeremy379-laravel-openid-connect)[ronvanderheijden/openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

61755.5k](/packages/ronvanderheijden-openid-connect)[facile-it/php-openid-client

OpenID (OIDC) Client

42592.7k7](/packages/facile-it-php-openid-client)[authlete/authlete-laravel

Authlete Library for Laravel

4226.0k](/packages/authlete-authlete-laravel)

PHPackages © 2026

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