authbucket/oauth2-php
Standards-compliant OAuth 2.0 (RFC6749) server library for PHP. Includes a Silex-based service provider for demos/tests and supports custom models/model managers (e.g., Doctrine) for tokens, clients, users, and scopes.
SecurityComponent, ValidatorComponent). Laravel’s dependency injection and middleware systems can partially accommodate this via bridges (e.g., symfony/http-foundation for request/response handling), but native Laravel integration requires custom adapters (e.g., wrapping controllers in Laravel middleware).oauth2_resource, oauth2_token).
Risk: Tight coupling with Symfony’s SecurityComponent may require Laravel-specific abstractions.HttpFoundation can be polyfilled in Laravel (e.g., via symfony/http-foundation package).authbucket_oauth2.authorization_controller in Laravel middleware).Illuminate\Container).auth system differs from Symfony’s; may need custom user provider adapters (e.g., UserProviderInterface → Laravel’s User model).ModelManager implementation.HttpTests) may not align with Silex’s WebTestCase.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony-Laravel Integration | High | Create Laravel-specific adapters (e.g., middleware for controllers, service provider bridge). |
| User Provider Mismatch | Medium | Implement a LaravelUserProvider wrapping Eloquent models to comply with UserProviderInterface. |
| Token Storage | Medium | Extend ModelManager to use Laravel’s cache (e.g., Illuminate\Cache) or database. |
| PKCE Support | Low | Package includes PKCE; ensure Laravel’s request handling (e.g., Illuminate\Http\Request) supports state/code_verifier. |
| Performance Overhead | Low | Benchmark Symfony vs. Laravel request lifecycle; optimize with Laravel’s caching. |
| Long-term Maintenance | Medium | Monitor package activity (stars/issues); consider forking if abandoned. |
users table and OAuth2.0’s UserProvider?league/oauth2-server or knuckleswtf/oauth2-laravel for tighter Laravel integration?symfony/http-foundation as a bridge for HttpFoundationInterface compatibility.Route::post('/oauth/token', ...) or middleware-based routing.ServiceProvider:
public function register() {
$this->app->singleton('authbucket_oauth2.model_manager', function ($app) {
return new AuthBucket\OAuth2\ModelManager\DoctrineModelManager(
$app->make('db.connection')->getDoctrineConnection()
);
});
}
Route::post('/oauth/token', function () {
return $this->app->make('authbucket_oauth2.token_controller')->indexAction();
})->middleware('oauth2_token'); // Custom middleware validating tokens.
UserProviderInterface:
class LaravelUserProvider implements UserProviderInterface {
public function loadUserByUsername($username) {
return User::where('email', $username)->firstOrFail();
}
}
oauth_clients, oauth_access_tokens) or extend the in-memory model manager with Redis/Memcached.OAuth2TokenMiddleware).Log facade for OAuth2.0 events).| Laravel Feature | Compatibility | Workaround |
|---|---|---|
| Eloquent ORM | Low (requires custom ModelManager) |
Extend DoctrineModelManager or use raw queries. |
| Laravel Auth | Medium (user provider mismatch) | Implement UserProviderInterface adapter for Eloquent. |
| Middleware System | High | Wrap package controllers in middleware (e.g., ValidateOAuthRequest). |
| Blade Templates | N/A (OAuth2.0 is API-focused) | Not applicable. |
| Queue Workers | Low (no built-in async support) | Use Laravel queues for token revocation/cleanup. |
| API Resources (Laravel 8+) | Medium (resource endpoints need custom protection) | Use oauth2_resource firewall via middleware. |
/oauth/authorize (authorization code flow)./oauth/token (token exchange)./oauth/debug (internal tooling; optional).oauth2_resource middleware after token endpoint is stable.symfony/http-foundation, symfony/security, etc., updated. Risk: Major Symfony version bumps may break compatibility.How can I help you explore Laravel packages today?