Microsoft Azure (Socialite Provider)
Laravel Socialite OAuth2 driver for signing users in with Microsoft Azure AD / Entra ID, with multi-tenant config and logout support.
Repository Health
Technical Analysis
SocialiteProviders/Microsoft-Azure plugs Azure Active Directory (Microsoft Entra ID) into Laravel Socialite as a standard OAuth2 driver. It builds the v2.0 authorize and token URLs, exchanges an authorization code for a Microsoft Graph access token, calls the /me endpoint, and maps the response into id, name, email, principalName, and mail fields on a Socialite User object — no manual Guzzle wiring required.
Because it extends Socialite’s AbstractProvider, the package follows the same authorize/token/redirect lifecycle as Socialite’s built-in drivers. Config keys for tenant, graph_url, and an outbound proxy let one application authenticate against multiple Azure AD tenants (single-tenant, common, organizations, or consumers) by swapping the SocialiteProviders\Manager\Config object per request, and a dedicated getLogoutUrl() helper clears the Azure session alongside the local one.
What You Get
- AbstractProvider-based OAuth2 driver wired for Azure AD’s v2.0 authorize/token endpoints
- Automatic mapping of Microsoft Graph /me responses to id, name, email, principalName, and mail
- getLogoutUrl() helper for signing out of both the app and the Azure AD session
- Per-tenant configuration via a Config object for multi-tenant SaaS apps
- Optional graph_url override and outbound proxy support for sovereign clouds or private networking
Common Use Cases
- Add ‘Sign in with Microsoft’ to a Laravel SaaS app for enterprise customers using Azure AD/Entra ID
- Support multiple Azure AD tenants in one app by resolving a different Config per request
- Pull a user’s display name, email, and userPrincipalName straight from Microsoft Graph at login
- Log a user out of the Laravel session and their Azure AD session together
Under The Hood
Architecture The package is a single-responsibility Socialite driver: Provider.php extends SocialiteProviders\Manager\OAuth2\AbstractProvider to build the Azure AD v2.0 authorize/token URLs and call Microsoft Graph, AzureExtendSocialite.php is a thin listener that registers the ‘azure’ driver on Socialite’s SocialiteWasCalled event, and User.php extends Socialite’s OAuth2 User to add principalName and mail accessors. There is no src/ subdirectory — PSR-4 maps the Azure namespace straight to the repo root, typical of how SocialiteProviders subtree-splits one provider out of its monorepo of providers.
Tech Stack PHP ^8.0 targeting Laravel via socialiteproviders/manager (^4.4), which in turn wraps league/oauth2-client and Guzzle. HTTP calls use GuzzleHttp\RequestOptions directly for form params, headers, and proxy configuration rather than a higher-level client wrapper. No build step, bundler, or frontend tooling — it is a pure Composer library consumed through Laravel’s service container and Socialite’s driver-resolution mechanism.
Code Quality No test files ship in this repo (it is a read-only subtree split of SocialiteProviders/Providers, so CI and tests likely live upstream rather than here). Method and property naming is clear and consistent with Socialite’s own driver conventions, PHP 8 return types are used on several methods, and error handling is implicit — HTTP failures propagate as Guzzle exceptions rather than being caught locally. No linter or CI config is visible in this split repo.
What Makes It Unique There is nothing technically novel here — it is a conventional OAuth2 Socialite driver, structurally identical to the dozens of other single-provider packages in the SocialiteProviders ecosystem. Its value is packaging and correctness (getting Azure AD’s v2.0 endpoints, tenant handling, and Graph field mapping right) rather than a distinctive technical approach.
Used by 2 apps in this directory
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira