facile-it/php-openid-client
Full OpenID Connect client for PHP supporting OAuth 2.0 authorization code, implicit and hybrid flows, discovery, dynamic client registration, UserInfo/ID tokens with JWT signing and encryption, refresh tokens, and token revocation/introspection.
Architecture fit: Strong fit for a Laravel application acting as an OpenID Connect Relying Party against a standards-compliant IdP. The package covers discovery, authorization code flow, ID token validation, UserInfo, refresh tokens, introspection, revocation, dynamic registration, and advanced OIDC features. It is framework-agnostic PHP, not a Laravel package, so the TPM should plan an adapter layer rather than expect turnkey Laravel auth integration.
Integration feasibility: Feasible via Composer with moderate integration work. Laravel must provide PSR-7/PSR-17/PSR-18 implementations, typically Guzzle or Symfony HTTP client plus PSR-7 factories. The package’s PSR-15 middleware cannot be dropped directly into Laravel’s HTTP middleware stack; use the service classes directly in Laravel controllers/middleware, or add a PSR-15 bridge. Laravel’s cache can back the package’s PSR-16 cache needs after version validation. Native Laravel sessions can handle state/nonce, or the package’s SessionCookieMiddleware can be used inside a PSR-15 sub-stack.
Technical risk: Medium. This is security-critical authentication code with cryptographic validation, JWKS caching, token refresh, and session/state handling. The package has low visible adoption (48 stars, 0 dependents), so maintainer and ecosystem risk must be owned internally. Version 1.0.0 drops PHP 8.1 and upgrades to web-token/jwt-library 4.x with breaking changes. Confirm support for required flows, especially PKCE, RP-initiated logout/session management, and multi-issuer routing, because these are common enterprise requirements and are not all explicit in the README.
Key questions:
TPM recommendation: Approve a time-boxed technical spike, not an immediate production commitment. Gate production on a security review, an IdP interoperability test, and a documented fallback/ownership plan.
Stack fit: Use the package as the OIDC protocol engine behind Laravel-native auth services. Register builders, issuer metadata, client metadata, and service classes in a Laravel service provider. Bind a PSR-18 HTTP client (Guzzle/Symfony), PSR-17 factories, and PSR-16 cache. Keep IdP configuration in Laravel config/env, not in code. Wrap the package in application services such as OidcLoginService, OidcCallbackService, and OidcUserProvisioner so controllers and auth guards do not depend directly on package classes.
Migration path: If replacing Socialite or custom OAuth, introduce OIDC as an additional login route first, then migrate users behind a feature flag. If building new auth, start with one confidential web client and authorization code flow. Use Laravel middleware/controllers for login, callback, refresh, and logout; use the package services directly rather than forcing PSR-15 middleware into Laravel. After login, map validated ID token/UserInfo claims to a Laravel user and authenticate via the standard guard/session. Keep existing password or SSO paths until OIDC is proven.
Compatibility: Validate PHP 8.2+ (1.0.0 drops 8.1), Laravel version, gmp extension availability, and web-token/jwt-library 4.x compatibility before commitment. Ensure the PSR-18 client and PSR-17 factories are installed and container-resolvable. Confirm Laravel cache implements PSR-16 on the target version. Avoid relying on undocumented PKCE or logout behavior until tested against the actual IdP.
Sequencing:
Maintenance: Treat this as a security-critical dependency. Pin versions, monitor releases/changelogs, run dependency scanning, and stage upgrades because JWT framework major versions can break behavior. With low adoption and zero dependents, assume higher internal ownership: document the integration, keep an upgrade runbook, and budget for patching or a fork if the package stalls.
Support: Community-supported package with no vendor SLA. The TPM should assign a named internal owner for OIDC configuration, security reviews, and IdP changes. Consider commercial support or a maintained fork only if the integration becomes business-critical.
Scaling: Cache issuer metadata and JWKS aggressively but safely, as the README recommends. Use shared Redis or equivalent across app instances so every request does not fetch discovery/JWKS. Configure HTTP timeouts, retries, and connection reuse. Store sessions in a shared store, not local files, and ensure token refresh concurrency is handled without stampedes.
Failure modes: Discovery endpoint unavailable; stale or rotated JWKS; clock skew; invalid ID token signature/claims; state/nonce mismatch; callback replay; expired/revoked refresh token; cache outage; IdP timeout; misconfigured redirect URI; claim mapping failures; missing logout support. Each needs explicit error handling, user-safe messages, alerting, and a runbook.
Ramp-up: Expect one to two weeks of engineer ramp-up for OIDC concepts, PSR interfaces, Laravel auth internals, and the package’s builder/service model. A spike plus security review is the right TPM control before committing roadmap capacity.
How can I help you explore Laravel packages today?