Skip to content

Make the route prefix configurable; move OAuth/SSO routes under it - #44

Merged
sambhav-aggarwal merged 1 commit into
mainfrom
feature/configurable_route_prefix
Jul 2, 2026
Merged

Make the route prefix configurable; move OAuth/SSO routes under it#44
sambhav-aggarwal merged 1 commit into
mainfrom
feature/configurable_route_prefix

Conversation

@sambhav-aggarwal

Copy link
Copy Markdown
Member

What

Adds route_prefix (NEEV_ROUTE_PREFIX, default neev) — one knob that namespaces every machine-facing route the package registers: the API namespace, web OAuth redirect/callback, tenant SSO, and /csrf-cookie. Blade UI pages (/login, /account/...) deliberately stay at the root — they're end-user page URLs, not API namespace. Route names are unchanged, so email links and route() calls are unaffected by a rename.

Setting NEEV_ROUTE_PREFIX=auth gives /auth/login, /auth/oauth/{service}/callback, /auth/sso/callback, etc.

Why this option (per docs/design-principles.md, layer 2)

  • The prefix is one of the few package strings end users actually see — browser URLs and the links in verification/password-reset emails. Real apps legitimately differ on it. Sanctum (sanctum.prefix) and Fortify (fortify.prefix) both made exactly this call.
  • Not hardcoded to auth: breaking for every consumer for zero functional gain, and auth is the most collision-prone namespace an app owns.
  • Not left as-is: the sanctioned customisation path (publish routes/neev.php, edit the prefix) was a trap — NeevAPIMiddleware hardcoded neev/mfa/... in the MFA-token route gate, so a renamed prefix silently broke MFA step-up. The gate now follows the configured prefix.

BREAKING — identity provider action required

Per Sam's call, everything machine-facing binds to the prefix, which moves three route groups:

Old New (default prefix)
/oauth/{service}[/callback] (web) /neev/oauth/{service}[/callback]
/sso/redirect, /sso/callback /neev/sso/redirect, /neev/sso/callback
/api/tenant/auth /neev/tenant/auth

Redirect URIs registered at identity providers (Entra/Google/Okta app registrations, OAuth apps) must be updated — documented with the full table in UPGRADING.md. The OAuth API controller's hand-built redirect URL now derives from the prefix too.

Testing

New CustomRoutePrefixTest boots the app with route_prefix=auth and proves: login under /auth/* (and 404 under /neev/*), authenticated API routes, the MFA-token route gate following the prefix, and SSO/csrf-cookie placement. Suite 995 green; Pint and PHPStan clean. Docs updated across api-reference, web-routes, multi-tenancy, authentication, installation, configuration, README, and the design-principles applied-decisions table.

New route_prefix config key (NEEV_ROUTE_PREFIX, default 'neev')
namespaces every machine-facing route the package registers — the API
namespace, web OAuth redirect/callback, tenant SSO, and /csrf-cookie.
Blade UI pages (/login, /account/...) stay at the root: they are
end-user URLs, not part of the API namespace. Route names are
unchanged, so nothing generated from names breaks.

Why a config value and not 'auth' or the status quo (per
docs/design-principles.md, layer 2):
- The prefix is one of the few package strings end users see (browser
  URLs, links in verification/reset emails), and real apps differ on
  it — the Sanctum ('sanctum.prefix') and Fortify ('fortify.prefix')
  precedent
- Hardcoding 'auth' would break every consumer for zero functional
  gain and collide with the most common app-owned route namespace
- 'Publish the routes file and edit it' was a trap: the MFA-token
  route gate in NeevAPIMiddleware hardcoded 'neev/...' paths, so a
  renamed prefix silently broke MFA step-up. The gate now follows the
  configured prefix

BREAKING: /oauth/{service}[/callback] -> /neev/oauth/...,
/sso/redirect|callback -> /neev/sso/..., /api/tenant/auth ->
/neev/tenant/auth. Redirect URIs registered at identity providers
(Entra/Google/Okta, OAuth apps) must be updated; documented in
UPGRADING.md. The OAuth API controller's hand-built redirect URL now
derives from the prefix as well.

4 new tests prove a custom prefix end-to-end (login, authenticated
routes, the MFA route gate, SSO/csrf-cookie). Suite 995 green; Pint
and PHPStan clean; all docs updated to the prefixed paths.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Caution

This repository is currently using the Sentry GitHub App to receive Codecov PR comments. This integration will be deprecated on July 8, 2026. Please install the Codecov GitHub App to continue receiving coverage reports on your pull requests.
❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/Http/Controllers/Auth/OAuthApiController.php | 0.00% | 2 Missing ⚠️ |

📢 Thoughts on this report? Let us know!

@sambhav-aggarwal
sambhav-aggarwal merged commit 23b31a9 into main Jul 2, 2026
4 checks passed
@sambhav-aggarwal
sambhav-aggarwal deleted the feature/configurable_route_prefix branch July 2, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants