binhvd/oauth2-server-httpfoundation-bridge
Bridge package that integrates an OAuth2 server with Symfony HttpFoundation, providing request/response adapters so you can use HttpFoundation objects when working with OAuth2 flows in Laravel/PHP applications.
/oauth/token, /oauth/authorize).symfony/http-foundation), so no additional dependencies are needed beyond oauth2-server-php and this bridge.Request, Response objects).oauth2-server-php (active but niche library; ensure version compatibility).symfony/http-foundation), so no additional setup is needed.ValidateOAuthToken).league/oauth2-server (the underlying library) for full OAuth2 functionality.Illuminate\Support\Facades\Request/Response for seamless integration.oauth2-server-php:
composer require league/oauth2-server binhvd/oauth2-server-httpfoundation-bridge
AppServiceProvider:
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\ResourceServer;
use Binhvd\OAuth2Server\HttpFoundation\Bridge;
public function register()
{
$this->app->singleton(AuthorizationServer::class, fn() => new Bridge\AuthorizationServer());
$this->app->singleton(ResourceServer::class, fn() => new Bridge\ResourceServer());
}
routes/api.php:
Route::post('/oauth/token', [OAuthController::class, 'issueToken']);
Route::get('/oauth/authorize', [OAuthController::class, 'authorize']);
class ValidateOAuthToken
{
public function handle(Request $request, Closure $next)
{
$resourceServer = app(ResourceServer::class);
$request = Bridge\Request::createFromGlobals();
$response = Bridge\Response::createFromGlobals();
if (!$resourceServer->validateAuthenticatedRequest($request, $response)) {
abort(401);
}
return $next($request);
}
}
EntityRepositoryInterface for Laravel’s database (e.g., Eloquent models).Request, Response).league/oauth2-server and oauth2-server-httpfoundation-bridge for breaking changes.league/oauth2-server docs/community.\Log::debug()) should be used liberally for OAuth2 events.| Issue Type | Support Level | Mitigation |
|---|---|---|
| HTTP Request Parsing | Medium (bridge risk) | Unit tests for edge cases |
| Token Storage | High (custom) | Use Laravel’s cache/database |
| Grant Validation | Medium (library) | Extend GrantType classes |
| Laravel Integration | High (direct) | Middleware for seamless flow |
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Token Validation Bypass | Security breach | Strict middleware + rate limiting |
| Database Token Storage Failure | Token loss | Multi-region Redis fallback |
| HttpFoundation Incompatibility | Request parsing failures | Feature flags for fallback logic |
| Grant Type Misconfiguration | Auth flow breaks | Input validation + logging |
| Dependency Vulnerabilities | Exploits | Regular ` |
How can I help you explore Laravel packages today?