spomky-labs/oauth2-server-bearer-token
Adds RFC 6750 Bearer Token support to the Spomky-Labs OAuth2 Server for PHP, enabling standard OAuth2 bearer token handling for authorization and protected API resource requests.
What this package actually is. spomky-labs/oauth2-server-bearer-token is not a standalone OAuth2 server and not a Laravel package. It is a narrow extension to spomky-labs/oauth2-server (part of the Spomky-Labs OAuth2 Framework family) that contributes RFC 6750 bearer-token handling — token type registration, Authorization: Bearer parsing, and the associated error responses (invalid_token, insufficient_scope, WWW-Authenticate challenge headers). Its value is entirely contingent on already running the parent server. On its own it does nothing.
Architecture fit. The parent library is a PSR-7/PSR-15-oriented, framework-agnostic authorization server. It composes grant types, token repositories, and middleware through dependency injection, with no Laravel service provider, facade, config publishing, migrations, or Eloquent bindings. That is a real mismatch with a Laravel codebase: adopting this means hand-wiring the entire server pipeline into the container, adapting Laravel's request/response cycle to PSR-7, and implementing storage contracts (client, access token, refresh token, scope) from scratch. The bearer-token package is a small fraction of that total integration cost — likely under 5% of the effort.
Integration feasibility. Technically possible, practically unattractive. The main friction points are:
psr/http-message ^1.0) and older zend-diactoros/nyholm/psr7 releases. Modern Laravel stacks have moved to PSR-7 v2 and PHP 8.2+. A composer update at the framework level is likely to produce conflicts.composer.json require constraints before any commitment — this is the single most likely hard blocker.Technical risk. This is the section that should stop the discussion. The metrics (0 score, no stars, 0 dependents) are not merely a popularity signal in isolation — for authentication code they are a governance signal:
--ignore-platform-reqs and eventually block framework upgrades.Key questions to resolve before proceeding.
spomky-labs/oauth2-server itself still maintained, and what is its current release cadence and PHP constraint?require constraints (PHP, PSR-7, parent version)?league/oauth2-server, and in Laravel specifically laravel/passport.)Stack fit. Poor as a direct fit, and the framing of "Laravel/PHP package" should be corrected internally: it is a PHP package that happens to be installable by Composer into a Laravel project. Laravel's own OAuth2 story is laravel/passport (built on league/oauth2-server), which ships migrations, guards, scopes, artisan commands, and a supported upgrade path. Any evaluation of this package has to justify why that is being rejected — and there is no apparent reason it would be.
Recommended path (greenfield or upgradeable). Do not adopt. Use laravel/passport for first-party OAuth2, or league/oauth2-server directly if we need framework independence. Both have active maintenance, security advisories, and a decade of production use. If the requirement is machine-to-machine tokens only, Laravel Sanctum is a lighter option that avoids the full authorization-server surface.
Contingency path (already committed to Spomky-Labs). If a legacy service already runs the Spomky server, this package is a reasonable way to keep bearer-token behavior consistent rather than hand-rolling it. In that case:
TokenAuthenticator interface so the dependency is confined to one adapter class.WWW-Authenticate headers, malformed-header handling, expired tokens, and scope insufficiency — these are the behaviors we would otherwise inherit untested.Migration path off the parent stack. The exit cost is low precisely because the package is small: its surface is token-type registration and header parsing, on the order of a few hundred lines. Reimplementing equivalent behavior on league/oauth2-server is a contained piece of work, but the storage contracts and grant-type wiring around it are not — that is the real migration. Budget the migration at the server level, not the bearer-token level.
Compatibility and sequencing.
Maintenance. Effectively unbudgeted. With no maintainer activity and no consumers, we are the maintainers — any bug fix is a fork. Realistic ongoing cost is small in lines of code but non-zero in attention: someone must monitor PHP releases, PSR interface bumps, and the parent server's status, and translate those into a private patch. Compare against Passport, where that work is externalized to an active community.
Support. There is no support channel to escalate to: no issue triage, no documentation beyond what the parent project offers, no Stack Overflow corpus for this specific package. On-call engineers debugging a 401 in production will be reading source. That is an acceptable trade for a well-known library and a poor one for a package with zero dependents.
Scaling. Functionally this is the least concerning dimension. Bearer-token validation is stateless header parsing plus a token-store lookup; the package itself adds negligible CPU. Scale characteristics are determined by the token repository (database or cache), not by this code. The scaling risk is organizational, not technical: as the service grows, the constraint-anchor effect of an old PSR-7 dependency compounds, and the eventual forced migration happens under pressure rather than on our schedule.
Failure modes to plan for.
Authorization header edge case (multiple spaces, case sensitivity, malformed token) producing an incorrect 401/403 or, worse, permissive validation. Contract tests are the mitigation.Ramp-up. Higher than the package size suggests. An engineer must learn the Spomky OAuth2 Framework's composition model (grant types, token type registration, PSR-15 middleware ordering) rather than Laravel idioms they already know. Estimate 2–3 sprints to first production token issuance if building the full server integration, versus roughly one sprint for Passport with substantially less bespoke code. The bearer-token package itself is a few hours of reading; the surrounding server is the cost.
Bottom line. The technical merit of the code is not in question — it is a small, focused piece of a coherent framework. The problem is the operating context: unmaintained, unused, outside our framework's idioms, and sitting directly on the authentication boundary. Recommend closing the evaluation and standardizing on laravel/passport (full OAuth2) or laravel/sanctum (first-party tokens), retaining this package only as a documented contingency for any pre-existing Spomky-Labs deployment.
How can I help you explore Laravel packages today?