socialite or custom OAuth integrations). This aligns with Laravel’s modular, package-based architecture.league/oauth2-client (v1.3.0+), which Laravel projects likely already use or can easily adopt.pathAuthorize, pathToken) for B2C or custom Azure setups.| Risk Area | Mitigation | Severity |
|---|---|---|
| Azure AD Versioning | Package supports both v1.0 and v2.0 endpoints, but v2.0 is recommended. Ensure app registration uses correct endpoints. | Medium |
| Token Management | Requires manual handling of refresh tokens and expiry checks (e.g., in middleware). | High |
| B2C/Experimental Features | Limited testing; may require customization for edge cases (e.g., B2C policies). | Medium |
| Certificate Auth | Complex setup (key generation, thumbprint management). Requires DevOps coordination. | High |
| Microsoft Graph Changes | Microsoft Graph API evolves; package may lag in supporting new endpoints (e.g., /v1.0 vs /beta). |
Low |
| State Management | Relies on Laravel Sessions; ensure session driver is configured (e.g., file, redis). |
Medium |
AppServiceProvider:
$this->app->singleton(TheNetworg\OAuth2\Client\Provider\Azure::class, function ($app) {
return new Azure([
'clientId' => config('services.azure.client_id'),
'clientSecret' => config('services.azure.client_secret'),
'redirectUri' => config('services.azure.redirect_uri'),
]);
});
public function handle($request, Closure $next) {
$token = $request->bearerToken();
$provider = app(Azure::class);
$provider->validateAccessToken($token);
return $next($request);
}
users table or a oauth_tokens table.Schema::create('oauth_tokens', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->text('access_token');
$table->text('refresh_token')->nullable();
$table->timestamp('expires_at');
$table->timestamps();
});
Cache::remember("graph_user_{$userId}", now()->addHours(1), function () use ($token, $provider) {
return $provider->get($provider->getRootMicrosoftGraphUri($token) . '/me', $token);
});
openid).config/services.php).| Component | Compatibility Notes |
|---|---|
| Laravel Versions | Tested with Laravel 8+ (PHP 7.4+). May require adjustments for older versions (e.g., PSR-15 middleware). |
| PHP Versions | Requires PHP 7.4+ (due to League OAuth2 Client dependencies). |
| Azure AD Tenant | Works with single-tenant, multi-tenant, and B2C (experimental). |
| Microsoft Graph | Supports /v1.0 and /beta; ensure app permissions are configured in Azure Portal. |
| Database | No strict requirements; works with MySQL, PostgreSQL, SQLite. |
https://yourapp.com/auth/azure/callback).openid, User.Read).composer require thenetworg/oauth2-azure league/oauth2-client
Route::get('/auth/azure', [AzureAuthController::class, 'redirectToAzure']);
Route::get('/auth/azure/callback', [AzureAuthController::class, 'handleAzureCallback']);
get() methods to call Microsoft Graph.$user = $provider->get($provider->getRootMicrosoftGraphUri($token) . '/me', $token);
getLogoutUrl().thenetworg/oauth2-azure and league/oauth2-client for breaking changes.How can I help you explore Laravel packages today?