Illuminate\Auth) is fundamentally different, requiring significant abstraction or middleware workarounds.jumbojett/OpenID-Connect-PHP (a battle-tested OIDC library), ensuring standard compliance (RFC 6749, 6750, 7519). This is a strength for Laravel, which lacks a native OIDC solution.Guard/UserProvider interfaces, not Symfony’s AuthenticatorInterface. A custom middleware or Laravel Auth extension would be needed to bridge the gap.security.yaml is replaced by Laravel’s auth.php/middleware. The oidc listener would need to be emulated via middleware (e.g., OidcAuthMiddleware).LogoutEvent/LoginEvent would require Laravel’s Authenticating/Authenticated events or custom listeners.drenso_oidc.yaml can be mapped to Laravel’s config/oidc.php using Laravel’s config system.OIDC_WELL_KNOWN_URL) are natively supported in Laravel via .env.OidcUserProviderInterface must be adapted to Laravel’s UserProvider contract. The ensureUserExists() and loadOidcUser() methods would need Laravel equivalents (e.g., retrieveByOidc()).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Authentication Flow Mismatch | High | Build a Laravel-compatible authenticator (e.g., OidcGuard) or use middleware. |
| Middleware Complexity | Medium | Abstract OIDC logic into a service class (e.g., OidcService) to decouple from Symfony. |
| PHP 8+ Requirement | High | Block adoption if Laravel app isn’t PHP 8+; otherwise, upgrade. |
| Remember Me/Logout | Medium | Implement custom cookie-based remember-me and OIDC RP-initiated logout logic. |
| Token Validation | Low | Reuse OpenID-Connect-PHP’s validator under the hood; minimal risk. |
| IdP-Specific Quirks | Low | Bundle includes docs for Microsoft Entra/ADFS; other IdPs may need testing. |
User model be extended to implement OidcUserProviderInterface?
league/oauth2-server, php-openid/connect) that could be composed with this bundle?
end_session_endpoint (logout) fails?
OpenID-Connect-PHP library is IdP-agnostic and can be used directly in Laravel (e.g., via league/oauth2-client). The Symfony bundle is just a wrapper for this library + Symfony auth integration.AppServiceProvider.oidc listener with a custom OidcAuthMiddleware.Authenticating, Authenticated, and Attempting events for hooks.REMEMBERME via Laravel’s cookie() helper.AuthenticationManager or AuthenticatorInterface.security.yaml (use Laravel’s auth.php/middleware.php).Phase 1: Dependency Extraction
league/oauth2-client and php-openid/connect as Laravel dependencies.OidcService).// app/Services/OidcService.php
use League\OAuth2\Client\Provider\GenericProvider;
use Jose\Component\Core\JWK;
class OidcService {
public function getClient(string $clientName): GenericProvider {
// Load config from Laravel's config/oidc.php
$config = config("oidc.clients.$clientName");
return new GenericProvider($config);
}
public function validateToken(string $token): array {
// Reuse OpenID-Connect-PHP validation logic
return (new \OpenID\OpenID())->validateToken($token);
}
}
Phase 2: Authentication Middleware
oidc listener).// app/Http/Middleware/OidcAuthMiddleware.php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\RedirectResponse;
class OidcAuthMiddleware {
public function handle($request, Closure $next) {
if (!$request->user()) {
$oidc = app(OidcService::class);
return $oidc->generateAuthorizationRedirect();
}
return $next($request);
}
}
app/Http/Kernel.php:
protected $middleware = [
// ...
\App\Http\Middleware\OidcAuthMiddleware::class,
];
Phase 3: User Provider Integration
UserProvider to handle OIDC user data.// app/Providers/OidcUserProvider.php
use Illuminate\Contracts\Auth\UserProvider;
use OpenID\OpenID;
class OidcUserProvider implements UserProvider {
public function retrieveByOidc(string $identifier) {
// Fetch user from DB using OIDC identifier (e.g., 'sub' or 'email')
}
public function createUserFromOidc(array $userData) {
// Bootstrap new user from OIDC claims
return User::create([
'email' => $userData['email'],
'provider_id' => $userData['sub'],
]);
}
}
Phase 4: Configuration Adaptation
drenso_oidc.yaml to Laravel’s config/oidc.php:
// config/oidc.php
return [
'clients' => [
'default' => [
'well_known_url' => env('OIDC_WELL_KNOWN_URL'),
'client_id' => env('OIDC_CLIENT_ID'),
'client_secret' => env('OIDC_CLIENT_SECRET'),
'redirect_uri' => env('OIDC_REDIRECT_URI'),
],
],
];
Phase 5: IdP-Specific Tweaks
access_token_issuer quirk) in the OidcService.if ($idp ===
How can I help you explore Laravel packages today?