Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 936bd09500
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return options.nodeEnv === 'production' || options.isHttps || options.isLocalhost | ||
| } | ||
|
|
||
| export function getAuthCookieSameSite(input?: AuthCookiePolicyInput): AuthCookieSameSite { | ||
| return getAuthCookieSecure(input) ? 'none' : 'lax' |
There was a problem hiding this comment.
Keep auth session cookies Lax outside iframe flows
getAuthCookieSameSite() now returns none whenever cookies are secure, and getAuthCookieSecure() returns true for all production requests, so every production session cookie becomes SameSite=None. That causes the auth cookie to be sent on cross-site requests, while many mutating endpoints (for example app/api/api-keys/route.ts POST/DELETE) authenticate only via getSessionFromReq and do not perform origin/CSRF checks, which enables cross-site request forgery from third-party sites. Limit SameSite=None to explicitly embedded iframe contexts and keep Lax as the default for normal sessions.
Useful? React with 👍 / 👎.
Summary
/api/auth/info.Root Cause
GitHub OAuth was completing and writing users/sessions, but the app was embedded under a different top-level site. The session cookie was written as
SameSite=LaxwithoutSecurefor localhost development, so iframe requests to/api/auth/infodid not include the session cookie.Validation
pnpm exec tsx --test lib/auth/iframe-oauth.test.tspnpm formatpnpm format:checkpnpm type-checkpnpm lintNotes
The worktree still contains unrelated local changes that are not included in this PR.