raiolanetworks/simple-oauth2-client
Simple OAuth2 client for PHP and Laravel projects that streamlines authorization code flows, access token exchange, and refresh token handling. Lightweight and easy to configure, it helps integrate third-party OAuth providers and secure API authentication without boilerplate.
preserve_intended_url (default true) means a user who follows a shared link to a gated page is returned there after authenticating instead of being dumped on a generic success route. This is a measurable funnel decision, not a cosmetic one: it affects activation on invite links, shared documents, checkout deep links, and email campaign landing pages. PMs can now treat "authenticate mid-journey" as a supported path rather than a leak, and should instrument it (drop-off before vs. after login, post-login destination distribution) before assuming the default is right for every surface.route_prefix (default oauth) lets the callback live at /auth/callback or any brand-aligned path. Useful when the default path collides with an existing route, when multiple auth flows must coexist under distinct prefixes, or when a customer-facing URL is part of the product story. Route names are unchanged (oauth.request, oauth.callback), so this is a low-risk presentation change without a code-wide refactor — a cheap way to satisfy a design or platform review.APP_URL plus the actual route path, so the value announced to the provider cannot drift from the route that serves the callback. Previously, publishing config without running oauth:install advertised the bare domain, and any non-default callback path produced a 404 after the user had already authenticated — the worst failure mode, since the user has spent effort and is then dropped. For a PM this is a defect class worth closing before scaling any acquisition spend into an OAuth-gated funnel.APP_URL rather than the incoming request — which is exactly the kind of thing an in-house implementation gets wrong behind a TLS-terminating reverse proxy or with a spoofable Host header. That is engineering time and incident risk a team does not need to re-derive.Adopt when:
Host/scheme from the request — the APP_URL-rooted redirect URI is a genuine correctness advantage here.route_prefix makes this a config change plus one provider registration, not a fork.Look elsewhere or pause when:
OAuthController to serve the callback at a custom path. This is the one setup requiring action: OAUTH_CALLBACK_URI is no longer read, and the advertised URI now follows the package route. Either set OAUTH_ROUTE_PREFIX to that same prefix or register the new URI with your provider. Budget the provider-side change and a comms note; get this wrong and every login fails immediately after deploy.APP_URL is not a single stable value per deployment. The fix intentionally ignores the incoming request, so per-tenant hostnames need to be resolved at config/runtime level, not by relying on request introspection.For executives: This release removes the most expensive kind of login failure — the one that happens after the user has already authenticated — and keeps users on the path they came for. Two things matter commercially. First, deep links now survive login by default, so acquisition spend on shared links, invites, and email campaigns is no longer partially wasted at the sign-in wall. Second, the redirect URI is now derived from a single source of truth (APP_URL plus the real route), which eliminates a configuration class that failed silently on the provider's side and generated support tickets we could not reproduce locally. Cost to adopt is near zero: a dependency bump, an optional config change if we want a branded callback path, and one provider dashboard update only if we are in the small group with custom callback routes.
For engineering: The security-relevant change is that the redirect URI is rooted in APP_URL and never in the incoming request. That closes three real failure modes at once: http:// advertised behind a TLS-terminating proxy (since TrustProxies is not enabled by default in Laravel 11+), a spoofable Host header, and APP_URL being ignored on a local server — each producing an unregistered URI and a hard login failure. Advertised URI and served route can no longer disagree, so publishing config without running oauth:install no longer advertises the bare domain.
Migration asks: One audit item, not a refactor. OAUTH_CALLBACK_URI (config key oauth.callback) is no longer read. The key is retained so published configs keep loading, but it has no effect — so a stale value will not error, it will just be ignored. Set OAUTH_ROUTE_PREFIX if we need a custom path. The only setup requiring action is one that registered its own routes against OAuthController and matched OAUTH_CALLBACK_URI to it: align the prefix or register the new URI with the provider before deploying. oauth:install now prompts for the prefix and prints the exact redirect URI to register, which should be our go-to for verification rather than reading config by hand. Route names are unchanged, so existing route() calls keep working.
How can I help you explore Laravel packages today?