Looking to hire Laravel developers? Try LaraJobs

laravel-azure-socialite maintained by ashwini-gt

Description
Azure SSO package for Laravel using Socialite
Last update
2026/09/01 20:19 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus
Laravel Azure Socialite Azure SSO package for Laravel using Socialite and Microsoft Azure AD. Features Microsoft Azure AD Login Laravel Socialite Integration Route Middleware (azure.sso) Automatic Azure Login Redirect Azure Callback Handling Session-Based Authentication Laravel 9, 10, and 11 Support Package Auto Discovery Installation Install the package using Composer: composer require ashwini-gt/laravel-azure-socialite Install required dependencies if not already installed: composer require laravel/socialite composer require socialiteproviders/microsoft-azure Publish Configuration Publish the configuration file: php artisan vendor:publish --tag=config This will create: config/azure.php Environment Configuration Add the following values to your .env file: AZURE_TENANT_ID= AZURE_CLIENT_ID= AZURE_CLIENT_SECRET= AZURE_REDIRECT_URI=http://localhost:8000/azure/callback Example: AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx AZURE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx AZURE_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx AZURE_REDIRECT_URI=http://localhost:8000/azure/callback Laravel Services Configuration Add Azure configuration in: config/services.php 'azure' => [ 'client_id' => env('AZURE_CLIENT_ID'), 'client_secret' => env('AZURE_CLIENT_SECRET'), 'redirect' => env('AZURE_REDIRECT_URI'), 'tenant' => env('AZURE_TENANT_ID'), ], Middleware Usage Protect routes with Azure SSO: Route::middleware(['azure.sso'])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); }); }); Available Routes The package automatically registers: GET /azure/login GET /azure/callback Login Flow User Accesses Protected Route | V Azure Middleware | V /azure/login | V Microsoft Login | V /azure/callback | V Session Created | V Redirect Home Session Variables After successful authentication: session('azure_user'); session('azure_token'); Example: $user = session('azure_user'); $email = $user->email; $name = $user->name; Route Examples Manual login: {{ route('azure.login') }} Login with Microsoft Check user: if(session()->has('azure_user')){ // Authenticated } Supported Laravel Versions Laravel Version Supported9.x ✅ 10.x ✅ 11.x ✅ Requirements PHP 8.1+ Laravel 9+ Laravel Socialite Microsoft Azure App Registration Azure App Registration Settings In Azure Portal: Redirect URI http://localhost:8000/azure/callback Production Example: https://your-domain.com/azure/callback API Permissions User.Read Grant Admin Consent after adding permissions. Troubleshooting Driver [azure] not supported Install: composer require socialiteproviders/microsoft-azure Clear cache: php artisan optimize:clear Invalid Redirect URI Verify: AZURE_REDIRECT_URI= matches exactly with Azure Portal Redirect URI. Route Not Found Verify routes are loaded: php artisan route:list Expected: azure.login azure.callback License This package is open-sourced software licensed under the MIT License. Author Ashwini Bind GitHub: https://github.com/ashwini-gt Package: https://github.com/ashwini-gt/laravel-azure-socialite