spomky-labs/oauth2-server-token-endpoint
Ready-to-use OAuth2 token endpoint for PHP from spomky-labs. Integrates with the OAuth2 server to process token requests, validate grant types, and issue access tokens via a PSR-7 compatible, middleware-friendly implementation for secure API authorization and token lifecycle management.
This package is not a standalone OAuth2 server and not, strictly, a Laravel package. It is a framework-agnostic, PSR-oriented component that implements the /token endpoint handler for the Spomky-Labs OAuth2 server family — the piece that authenticates clients, validates grant types (authorization code, client credentials, password, refresh token), and issues access and refresh tokens. Adopting it means adopting the surrounding core server, an authorization endpoint, a resource server, and storage adapters, none of which are included here. That is the first architectural finding: the unit under evaluation cannot be deployed alone, so the real dependency footprint is several sibling packages with correlated abandonment risk.
The design fit with Laravel is poor. Laravel already ships a framework-native answer to this exact problem in Laravel Passport, which is itself a wrapper around league/oauth2-server and provides service-provider bindings, guards, migrations, scopes, and an opinionated storage layer. This package instead expects a PSR-11 container, a PSR-7 request/response pair, and a PSR-15 style handler. Making it work inside Laravel's HTTP kernel requires a container bridge, a PSR-7/PSR-17 bridge, bespoke route registration outside the normal controller flow, and hand-written repository implementations against Eloquent or the query builder. Every one of those glue layers sits directly on the security-critical path — client authentication and token issuance — and would be ours to write, test, and review.
The integration feasibility is therefore "possible but unjustified." The risk profile is high on multiple independent axes. The dataset shows zero stars, a score of zero, and zero dependents; while zero stars may partly reflect a subtree split from a monorepo rather than true obscurity, zero dependents is meaningful because it means nobody declares this package directly in production and there is no ecosystem to surface integration bugs. The sibling project lineage is widely understood to be archived or deprecated as Spomky-Labs shifted focus to JWT and WebAuthn tooling, which means no PHP 8.x maintenance, no security advisories, and no compatibility work. Transitive constraints from a PHP 7-era PSR-7 v1 ecosystem are likely to conflict with Laravel 9/10/11 dependency graphs. Because the token endpoint is the highest-value attack surface in any OAuth2 deployment — client secret brute force, authorization code replay, refresh token reuse, grant misconfiguration — betting it on an unmaintained library and self-authored glue is a risk concentration we would have to consciously accept and fund.
Key questions to resolve before any decision: What is the last commit and last tagged release, and is the parent repository archived? What PHP and PSR-7/PSR-15 version constraints does the current composer.json carry, and does it resolve on PHP 8.1+? Are there known CVEs in the transitive set (container, event dispatcher, HTTP message implementations)? Does it support the grants we actually need, including PKCE for public clients and RFC 7523 JWT bearer assertions? Is token format pluggable between opaque and JWT, and who owns signing key rotation? Which storage repositories ship in-tree versus which must be implemented? What is the license, and is the code reviewed enough to fork and own? And the decisive one: what does this package do that Laravel Passport does not already do for us?
Stack fit is the crux. Laravel's authentication architecture assumes a guard, a user provider, and a service provider; Passport satisfies all three out of the box. This package supplies none of them and expects to sit behind a middleware pipeline of our construction. A Laravel integration would require a package-level service provider binding the PSR container to Laravel's container, a PSR-7 bridge (for example a Symfony or Nyholm bridge) at the route boundary, a dedicated controller or middleware that translates Laravel's request into a PSR-7 request and the response back, and repository classes implementing the package's storage interfaces against Eloquent models we design. Config, migrations for clients/tokens/scopes, pruning commands, and test fixtures all become ours. That is a full subsystem rewrite with the vendor supplying only the protocol logic.
The migration path is narrow. This is defensible only in one scenario: an existing application already running the Spomky-Labs server that is being ported into a Laravel codebase and where a rip-and-replace is out of scope for the current release. For greenfield work, or for a Laravel app currently on Passport or Sanctum, adoption would be a regression in maintainability with no offsetting capability. The recommended path is to standardize on Laravel Passport for full OAuth2 server needs and Sanctum for first-party SPA and API token needs, and to treat this package as a reference implementation to read rather than a dependency to install.
Compatibility verification is a gating step and should be time-boxed. Pin the exact PHP version range from composer.json, attempt a resolution against our target Laravel version in a throwaway branch, and record the conflicts. Expect PSR-7 v1 versus v2 friction, and expect at least one abandoned transitive package. If resolution fails, the evaluation ends there and no further effort is spent.
Sequencing, if we proceed at all: first, a two-day compatibility spike in an isolated non-Laravel container to prove the handler runs on our PHP version; second, a security review of the grant implementations and client authentication code, including timing-safe secret comparison and refresh token rotation semantics; third, a decision gate on fork-and-own versus abandon; fourth, only then the Laravel glue work, behind a feature flag, with the token endpoint exercised by conformance tests against RFC 6749 and RFC 6750 before any production traffic. Do not sequence the Laravel wrapper before the spike — the spike is likely to terminate the initiative cheaply, and that is the desired outcome.
Maintenance burden is the dominant cost and it lands entirely on us. There is no upstream to consume patches from, so we own PHP version bumps, PSR standard migrations, and any protocol hardening. Practically this means vendoring or forking the package into our monorepo, assigning a named owner, and adding it to the same review and patch cadence as first-party code. Without that commitment, the component will silently rot until a PHP upgrade forces an emergency rewrite of the authentication path — the worst possible time.
Support is thin. There is no community forum, no meaningful issue throughput, no third-party tutorials, and no Stack Overflow corpus for this specific package, so troubleshooting depends on internal expertise and reading source. Scaling characteristics are acceptable in principle because the token endpoint is IO-bound rather than compute-bound: it scales horizontally provided token and client storage is a shared, transactional datastore. The real scaling concerns are operational rather than architectural — rate limiting and lockout on client authentication to blunt secret brute force, connection pool sizing for the token issuance write path, refresh token table growth and pruning, and CPU headroom for JWT signing if that format is enabled.
Failure modes worth planning for: silent leakage of client secrets or authorization codes through verbose logging of request bodies; refresh token reuse going undetected because rotation and revocation semantics were implemented by us rather than inherited; clock skew causing spurious token rejection across nodes; signing key rotation executed without overlapping validity, causing a global authentication outage; dependency CVEs with no available patch, forcing an out-of-band fork; and grant misconfiguration, particularly the password grant left enabled in a production profile. Each of these is a plausible incident, and each would be mitigated by default in Passport.
Ramp-up is steep. An engineer joining this work needs OAuth2 RFC fluency, comfort with PSR-7/PSR-11/PSR-15 abstractions, and the patience to do archaeology on unmaintained code — three distinct skill sets for a component that is invisible when it works. Budget multiple weeks before the first competent change, and treat the security review as a recurring cost rather than a one-time gate. Net assessment: the package is a reasonable artifact of its era, but for a Laravel codebase in 2024 and beyond it carries more integration and ownership cost than the capability it delivers, and the maintained alternative is already in the framework's own ecosystem.
How can I help you explore Laravel packages today?