PHPackages                             zulficarjoy/socialite-azure-external-identities - 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. zulficarjoy/socialite-azure-external-identities

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

zulficarjoy/socialite-azure-external-identities
===============================================

Microsoft Entra External ID (Azure External Identities) OAuth2/OIDC provider for Laravel Socialite

v1.0.0(today)00MITPHPPHP ^8.2

Since Jul 28Pushed todayCompare

[ Source](https://github.com/zulficarjoy/socialite-azure-external-identities)[ Packagist](https://packagist.org/packages/zulficarjoy/socialite-azure-external-identities)[ Docs](https://github.com/zulficarjoy/socialite-azure-external-identities)[ RSS](/packages/zulficarjoy-socialite-azure-external-identities/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Azure External Identities Provider for Laravel Socialite
========================================================

[](#azure-external-identities-provider-for-laravel-socialite)

[![Latest Version on Packagist](https://camo.githubusercontent.com/42c65fb49d375b6297e80703d5b574c4760b3e0cae1f6e1e2b9ff1ea5a491067/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a756c66696361726a6f792f736f6369616c6974652d617a7572652d65787465726e616c2d6964656e7469746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zulficarjoy/socialite-azure-external-identities)[![Total Downloads](https://camo.githubusercontent.com/96a9514ccf9da65e49d087e00e0757c975f3177876600e81abaeb3d507191a7f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a756c66696361726a6f792f736f6369616c6974652d617a7572652d65787465726e616c2d6964656e7469746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zulficarjoy/socialite-azure-external-identities)[![License](https://camo.githubusercontent.com/ac574860b6f19ac2c43e0be146fa272d3698bd4084dfb5f41fac9632c93c4a57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a756c66696361726a6f792f736f6369616c6974652d617a7572652d65787465726e616c2d6964656e7469746965732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A Laravel Socialite provider for [Microsoft Entra External ID](https://learn.microsoft.com/en-us/entra/external-id/customers/) (formerly Azure AD B2C successor for customer identity). Authenticate external users against your CIAM tenant using the standard OAuth 2.0 authorization code flow with PKCE.

Features
--------

[](#features)

- Built for **Microsoft Entra External ID** (`.ciamlogin.com`) tenants
- OpenID Connect authorization code flow with **PKCE** enabled by default
- **ID token validation** via JWKS with configurable verification
- **Nonce** validation to mitigate replay attacks
- Optional **user flow / policy** support via the `p` parameter
- **Logout URL** helper for single sign-out
- Compatible with **Laravel 11 and 12**
- Works with [SocialiteProviders Manager](https://socialiteproviders.com/)

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

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12
- A Microsoft Entra External ID (CIAM) tenant with a registered application

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

[](#installation)

```
composer require zulficarjoy/socialite-azure-external-identities
```

Follow the [SocialiteProviders base installation guide](https://socialiteproviders.com/usage/) if you have not set up SocialiteProviders Manager yet.

### Register the provider

[](#register-the-provider)

#### Laravel 11+

[](#laravel-11)

Add the listener in `AppServiceProvider::boot()`:

```
use Illuminate\Support\Facades\Event;
use SocialiteProviders\AzureExternalIdentities\Provider;
use SocialiteProviders\Manager\SocialiteWasCalled;

Event::listen(function (SocialiteWasCalled $event) {
    $event->extendSocialite('azure-ei', Provider::class);
});
```

#### Laravel 10 and below

[](#laravel-10-and-below)

Add the listener to `app/Providers/EventServiceProvider.php`:

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        \SocialiteProviders\AzureExternalIdentities\AzureExternalIdentitiesExtendSocialite::class.'@handle',
    ],
];
```

> **Note:** If you use Composer's SocialiteProviders auto-discovery, the listener may be registered automatically via the package's `composer.json` extra configuration.

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

[](#configuration)

Add the following to `config/services.php`:

```
'azure-ei' => [
    'client_id' => env('AZURE_EI_CLIENT_ID'),
    'client_secret' => env('AZURE_EI_CLIENT_SECRET'),
    'redirect' => env('AZURE_EI_REDIRECT_URI'),

    // Required unless `authority` is set
    'tenant_subdomain' => env('AZURE_EI_TENANT_SUBDOMAIN'),
    'tenant_id' => env('AZURE_EI_TENANT_ID'),

    // Optional: override the full authority URL
    // 'authority' => 'https://contoso.ciamlogin.com/00000000-0000-0000-0000-000000000000/v2.0',

    // Optional: user flow / policy name (passed as the `p` parameter)
    // 'policy' => env('AZURE_EI_POLICY'),

    // Optional: verify ID token signature via JWKS (default: true)
    'verify_id_token' => env('AZURE_EI_VERIFY_ID_TOKEN', true),

    // Optional: HTTP proxy for outbound requests
    // 'proxy' => env('AZURE_EI_PROXY'),
],
```

### Environment variables

[](#environment-variables)

```
AZURE_EI_CLIENT_ID=your-application-client-id
AZURE_EI_CLIENT_SECRET=your-client-secret
AZURE_EI_REDIRECT_URI="${APP_URL}/auth/azure-ei/callback"
AZURE_EI_TENANT_SUBDOMAIN=contoso
AZURE_EI_TENANT_ID=00000000-0000-0000-0000-000000000000
# AZURE_EI_POLICY=B2X_1_signupsignin
# AZURE_EI_VERIFY_ID_TOKEN=true
```

### Finding your tenant values

[](#finding-your-tenant-values)

ValueWhere to find it`tenant_subdomain`Your CIAM domain prefix, e.g. `contoso` from `contoso.ciamlogin.com``tenant_id`Microsoft Entra admin center → External tenant → Overview → Tenant ID`client_id`App registration → Application (client) ID`client_secret`App registration → Certificates &amp; secretsThe provider builds the authority URL as:

```
https://{tenant_subdomain}.ciamlogin.com/{tenant_id}/v2.0

```

Alternatively, set `authority` directly if you need a custom configuration.

Usage
-----

[](#usage)

### Redirect to sign-in

[](#redirect-to-sign-in)

```
use Laravel\Socialite\Facades\Socialite;

Route::get('/login/azure-ei', function () {
    return Socialite::driver('azure-ei')->redirect();
});
```

### Handle the callback

[](#handle-the-callback)

```
Route::get('/auth/azure-ei/callback', function () {
    $azureUser = Socialite::driver('azure-ei')->user();

    // $azureUser->getId()       — object ID (oid) or subject (sub)
    // $azureUser->getEmail()    — email address
    // $azureUser->getName()     — display name
    // $azureUser->token         — access token
    // $azureUser->refreshToken  — refresh token (if offline_access granted)
    // $azureUser->user          — raw token claims
});
```

### Custom scopes

[](#custom-scopes)

```
return Socialite::driver('azure-ei')
    ->scopes(['openid', 'profile', 'email'])
    ->redirect();
```

### Stateless authentication

[](#stateless-authentication)

Useful for API-only flows:

```
$user = Socialite::driver('azure-ei')
    ->stateless()
    ->user();
```

### Logout

[](#logout)

Sign the user out of your application and redirect to Microsoft Entra External ID logout:

```
Auth::logout();
request()->session()->invalidate();
request()->session()->regenerateToken();

$logoutUrl = Socialite::driver('azure-ei')
    ->getLogoutUrl(route('login'));

return redirect($logoutUrl);
```

Security
--------

[](#security)

This provider enables several security measures by default:

FeatureDefaultDescriptionPKCEEnabledProtects the authorization code exchangeNonceEnabledBinds the ID token to the authentication requestID token verificationEnabledValidates signature, audience, and expiry via JWKSState parameterEnabledInherited from Socialite; prevents CSRF on callbackOpenID configuration and JWKS documents are cached for one hour to reduce latency.

To disable ID token signature verification (not recommended for production):

```
'verify_id_token' => false,
```

Mapped user attributes
----------------------

[](#mapped-user-attributes)

Socialite fieldToken claim`id``oid` or `sub``email``email`, `emails[]`, or `preferred_username``name``name``nickname``preferred_username``given_name``given_name``family_name``family_name``tenant_id``tid`Contributing
------------

[](#contributing)

Contributions are welcome. Please open an issue or pull request on [GitHub](https://github.com/zulficarjoy/socialite-azure-external-identities).

License
-------

[](#license)

The MIT License (MIT). Copyright (c) 2026 Zulficar Hasan Joy. See [LICENSE](LICENSE) for details.

Credits
-------

[](#credits)

- [Zulficar Hasan Joy](https://github.com/zulficarjoy)
- [Laravel Socialite](https://github.com/laravel/socialite)
- [SocialiteProviders Manager](https://github.com/SocialiteProviders/Manager)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/54574546?v=4)[Zulficar Hasan Joy](/maintainers/zulficarjoy)[@zulficarjoy](https://github.com/zulficarjoy)

---

Top Contributors

[![zulficarjoy](https://avatars.githubusercontent.com/u/54574546?v=4)](https://github.com/zulficarjoy "zulficarjoy (2 commits)")[![joykanj](https://avatars.githubusercontent.com/u/196939526?v=4)](https://github.com/joykanj "joykanj (1 commits)")

---

Tags

laraveloauthsocialiteoauth2microsoftazureactive directoryOpenID Connectazure-adentraoidcB2Cexternal\_idciamexternal-identities

### Embed Badge

![Health badge](/badges/zulficarjoy-socialite-azure-external-identities/health.svg)

```
[![Health](https://phpackages.com/badges/zulficarjoy-socialite-azure-external-identities/health.svg)](https://phpackages.com/packages/zulficarjoy-socialite-azure-external-identities)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M928](/packages/laravel-socialite)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M134](/packages/roots-acorn)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

24138.3k](/packages/kovah-laravel-socialite-oidc)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

121256.9k1](/packages/ellaisys-aws-cognito)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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