fix: start page authentication in the callback route - #482
Open
mitch-fultz wants to merge 2 commits into
Open
Conversation
Fixes DAX-3330. Preserve page-level guards without render-time cookie writes or speculative PKCE cookies.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes DAX-3330 — Linear issue
Problem and discovery
Anonymous Ask WorkOS QA generated the documented Next.js integration: default
authkitProxy()pluswithAuth({ ensureSignedIn: true })in a Server Component. We copied all six generated application files, includingAuthKitProvider, into a real Next 16.2.1 app with published AuthKit 4.3.1, Node SDK 10.13.0, and React 19.2.4.Fresh
/returned 200,/dashboardreturned 500 twice, and the explicit/loginRoute Handler returned 307. The dashboard error was:The SDK README and canonical docs recommend this pattern. This was an upstream SDK/context mismatch, not an invented API or an indexing bug.
Adjacent-commit checks in the same full Next fixture confirmed
4c3f27bredirects successfully and ebef6e7 (#388) fails when PKCE/state becomes mandatory. The later cookie-deferral change #432 is not the cause and is not reverted.Minimal reproduction
In a normal Next 16 App Router app with its root layout/provider, use:
Set
WORKOS_API_KEY,WORKOS_CLIENT_ID, a 32+ characterWORKOS_COOKIE_PASSWORD, andNEXT_PUBLIC_WORKOS_REDIRECT_URI=http://127.0.0.1:3000/callback, then run the app and request:curl -i -H 'Accept: text/html' http://127.0.0.1:3000/dashboardDummy credentials suffice to reproduce the failure; do not follow the eventual WorkOS redirect for this local check.
Change
code/staterequests retain callback validation, including malformed mixed requests. OAuth state cannot substitute for routing data. Schema failures use a generic error rather than exposing decrypted input through logs oronError. Per-flow cookie names and existing callback checks/cleanup remain unchanged; cookie options use the configured public URI, not an internal proxy origin.getSignInUrl()/getSignUpUrl()helpers in Route Handlers or Server Actions, not during rendering. No Ask-specific override or public getter API expansion.Verification
/dashboardnow returns a local 307 with no verifier cookie; its document start returns 307 with one matching cookie. Verified state/cookie equality, SHA-256 challenge/verifier equality, return path/query and byte-exact configured callback URI, including127.0.0.1and encoded query values.Linkprefetch/click in Chrome: no pre-click cookie or authorization request; callback RSC request returns 200/no cookie, followed by document navigation returning 307/one cookie. A loopback authorization sink, not hosted login, verified the cookie/state/challenge and return path. No real login or token exchange was performed.Release and documentation handoff
This PR does not publish the fix. npm consumers need the SDK release after merge. The scheduled
workos/workosREADME sync opens a separate docs review PR; that needs merge/deployment before canonical docs change. A complete SDK-source reindex is also needed for retrieved source coverage. SDK merge/indexing alone does not update both npm and canonical docs. No merge, release, deploy or production reindex was performed here.