taufik-t/uauth-oidc-client

OpenID Connect OAuth2 Provider for Laravel Socialite

0.0.3 2025-07-07 14:31 UTC

This package is auto-updated.

Last update: 2025-07-07 14:31:43 UTC


README

Laravel Support: v9, v10, v11 PHP Support: 8.1, 8.2, 8.3

Installation & Basic Usage

composer require taufik-t/uauth-oidc-client

Please see the Base Installation Guide, then follow the provider specific instructions below.

Add configuration to config/services.php

'uauth' => [
    'base_url' => env('UAUTH_BASE_URL'),
    'client_id' => env('UAUTH_CLIENT_ID'),
    'client_secret' => env('UAUTH_CLIENT_SECRET'),
    'redirect' => env('UAUTH_REDIRECT_URI'),
],

The base URL must be set to the URL of your OIDC endpoint excluding the .well-known/openid-configuration part. For example: If https://auth.company.com/.well-known/openid-configuration is your OIDC configuration URL, then https://auth.company.com must be your base URL.

Add provider event listener

Configure the package's listener to listen for SocialiteWasCalled events.

Laravel 11+

In Laravel 11, the default EventServiceProvider provider was removed. Instead, add the listener using the listen method on the Event facade, in your AppServiceProvider boot method.

Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('uauth', \SocialiteProviders\UAuth\Provider::class);
});

Laravel 10 or below

Add the event to your listen[] array in app/Providers/EventServiceProvider. See the Base Installation Guide for detailed instructions.

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\UAuth\UAuthExtendSocialite::class.'@handle',
    ],
];

Usage

You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

return Socialite::driver('uauth')->redirect();

Returned User fields

  • id
  • name
  • email

More fields are available under the user subkey:

$user = Socialite::driver('uauth')->user();

$locale = $user->user['locale'];
$email_verified = $user->user['email_verified'];

Customizing the scopes

You may extend the default scopes (openid email profile) by adding a scopes option to your OIDC service configuration and separate multiple scopes with a space:

'uauth' => [
    'base_url' => env('UAUTH_BASE_URL'),
    'client_id' => env('UAUTH_CLIENT_ID'),
    'client_secret' => env('UAUTH_CLIENT_SECRET'),
    'redirect' => env('UAUTH_REDIRECT_URI'),

    'scopes' => 'groups roles',
    // or
    'scopes' => env('UAUTH_SCOPES'),
],

Based on the work of jp-gauthier