Skip to content

Deprecate middleware auth gating across Next.js reference and guides - #3405

Closed
jacekradko wants to merge 4 commits into
jacek/deprecate-createroutematcher-foundationfrom
jacek/deprecate-createroutematcher-nextjs
Closed

Deprecate middleware auth gating across Next.js reference and guides#3405
jacekradko wants to merge 4 commits into
jacek/deprecate-createroutematcher-foundationfrom
jacek/deprecate-createroutematcher-nextjs

Conversation

@jacekradko

Copy link
Copy Markdown
Contributor

Stacked on #3404. Applies the deprecation across the Next.js reference and the guides that taught middleware gating.

The reference page is kept-but-wrapped: each auth-gating section keeps its existing anchor but gains the deprecation notice, token-type gating now points to auth({ acceptsToken }) at the route, and the Combine-Middleware example loses its auth.protect() line. In the guides, basic-rbac now leads with the page-level check, session-tasks elevates <RedirectToTasks />, geo-blocking and satellite-domains keep their middleware but drop the auth tail, the custom sign-in/up steps are framed as legacy, the CSP examples drop the auth gating that was never relevant to CSP, and the MCP guide stops special-casing .well-known.

Load-bearing bit to scrutinize: every surviving createRouteMatcher example moves from /foo(.*) to /foo/:path*. The (.*) form misses encoded newlines (a bypass) and over-matches /foobar; /:path* fixes both. Verified against the SDK's path-to-regexp.

@jacekradko
jacekradko requested a review from a team as a code owner May 29, 2026 21:26
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-docs Ready Ready Preview Jun 5, 2026 3:36am

Request Review

Wraps the auth-gating sections of the Next.js clerkMiddleware reference with the deprecation notice (keeping anchors and clerkMiddleware config intact), redirects token-type gating to auth({ acceptsToken }) at the route, and points readers to resource-level protection. Updates the guides that taught the pattern: basic-rbac now leads with page-level checks, session-tasks elevates <RedirectToTasks />, geo-blocking and satellite-domains keep their middleware but drop the auth tail, the custom sign-in/up steps are framed as legacy, CSP examples drop the irrelevant auth gating, and the MCP guide no longer special-cases .well-known. All surviving createRouteMatcher examples use the newline-safe :path* form instead of (.*).
The newline-bypass mechanism for (.*) maps to an unpublished advisory
(still embargoed), so the reference page should not describe it yet.
Keep the neutral :path* recommendation; the security framing returns
with the deprecation track once the CVE is public.
…n (nextjs)

Onboarding WARNING: drop the embargoed 'can be bypassed' assertion, keep the
not-a-security-boundary point via re-render + separate-route-model framing.
clerk-middleware NOTE: add a non-security reason for the :path* swap so it
can't be paired with bypass prose to reconstruct the unpublished fix.
@jacekradko
jacekradko force-pushed the jacek/deprecate-createroutematcher-nextjs branch from 5fad417 to 5701fe8 Compare June 5, 2026 03:22
basic-rbac: await the async checkRole() in setRole and AdminDashboard (a
negated Promise is always falsy, so the guard never fired), and add the
missing admin check to removeRole. The page argues resource-level protection
hardest; its sample guards must actually run.

geo-blocking, satellite-domains: give the 'protect at the resource' pointers a
one-line, embargo-safe why (keeps the check in sync with your routes) so the
de-gated examples don't read as arbitrary churn.
@jacekradko

Copy link
Copy Markdown
Contributor Author

Heads up: this PR is part of the createRouteMatcher deprecation stack, which is being re-stacked on top of #3426.

#3426 carries a reframed, positive-recommendation version of the shared middleware-auth-deprecation partial plus the reworked Next.js protect-pages guidance, and is intended to merge to main first. Once it lands, this stack will be rebased onto it and pared down to the deltas it doesn't already cover.

Keeping do not merge until the rebase, no action needed here yet.

@jacekradko

Copy link
Copy Markdown
Contributor Author

Superseded by #3426, now the canonical Next.js createRouteMatcher deprecation PR. The migration guide and @clerk/eslint-plugin reference (from #3452) are merged in, and the createRouteMatcher() deprecation notices are in place. Closing in favor of #3426 (head 468fc4df4), shipping coordinated with clerk/javascript#8994.

@jacekradko jacekradko closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants