abel/keycloak-bearer-only-adapter-bundle
Symfony bundle to secure APIs with Keycloak Bearer-Only clients. Provides adapter and configuration (issuer, realm, client id/secret) via Symfony Flex recipe or manual YAML/.env setup. Supports Keycloak distribution differences (e.g., /auth removal).
symfony/ux-live-component or symfony/panther for API testing).league/oauth2-server or php-keycloak/connect may offer tighter integration.spatie/laravel-keycloak) may provide more mature alternatives.symfony/http-client) to validate tokens server-side (but loses middleware elegance).BearerTokenAuthenticator logic into a Laravel Middleware or Service Provider (high effort, but feasible).%env() syntax, which Laravel replaces with env(). A configuration wrapper would be needed.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony-Laravel Gap | High | Evaluate php-keycloak/connect or build a custom adapter. |
| Maintenance Overhead | Medium | Bundle is unmaintained (last release: 2023-02-20). |
| Token Validation Logic | Low | Core OAuth2 logic is sound; risk lies in integration. |
| Keycloak Version Lock | Medium | Ensure Keycloak server version matches bundle’s tested versions. |
spatie/laravel-keycloak) viable?HttpClient).BearerTokenAuthenticator class and rewrite it as a Laravel Middleware or Service Provider (recommended for monolithic apps).php-keycloak/connect: More active, Laravel-friendly.league/oauth2-server for generic OAuth2 + Keycloak’s introspection endpoint.symfony/ux-live-component) to test the bundle.BearerTokenAuthenticator).HttpClient or API Gateway).Authorization: Bearer header./protocol/openid-connect/token/introspect).| Component | Compatibility Risk | Notes |
|---|---|---|
| Laravel 10.x | Medium | Symfony components may need polyfills. |
| Keycloak 20+ | Low | Bundle tested with older versions. |
| PHP 8.1+ | Low | No breaking changes expected. |
| Symfony DI | High | Laravel’s DI is incompatible. |
| PSR-15 Middleware | Medium | Laravel supports PSR-15 via middleware. |
Auth::user()).php-keycloak/connect as a fallback.%env(), which differs from Laravel’s env().
/introspect endpoint (latency risk).
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Keycloak Server Down | API Unavailable | Fallback to local JWT validation. |
| Token Validation Errors | Auth Rejections | Graceful degradation (e.g., allowlist IPs). |
| Symfony-Laravel Integration Bug | Silent Failures | Unit tests for middleware logic. |
| Environment Variable Mismatch | Config Failures | Use Laravel’s env() helpers. |
How can I help you explore Laravel packages today?