fix: allow self-hosted GitHub users without email#435
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughSelf-hosted authentication now passes OAuth account details into registration checks, permits existing OAuth accounts without email, and gates new email-based accounts on invitations. User creation performs missing-email validation inside the advisory-lock transaction. Unit tests cover these registration and creation paths. Self-hosting documentation specifies the GitHub App Email addresses permission as Read-only. Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/docs/self-hosting/overview.mdxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. apps/docs/self-hosting/railway.mdxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. apps/web/src/server/auth.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying usesend with
|
| Latest commit: |
78ad751
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f9e782c3.usesend.pages.dev |
| Branch Preview URL: | https://codex-fix-self-hosted-github.usesend.pages.dev |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/server/auth.ts (1)
62-71: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winScope the email fallback away from OAuth sign-ins. Both GitHub and Google enable
allowDangerousEmailAccountLinking, so a new OAuth login with a matching email can skip the invite check here. Restrict this branch to non-OAuth flows, or to already-linked accounts.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/server/auth.ts` around lines 62 - 71, Update the email-based existing-user fallback in the authentication flow to run only for non-OAuth sign-ins or users whose account is already linked to the current OAuth provider. Preserve the existing invite-check behavior for new OAuth users with matching emails, using the provider/account-linking context available around this branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/src/server/auth.ts`:
- Around line 62-71: Update the email-based existing-user fallback in the
authentication flow to run only for non-OAuth sign-ins or users whose account is
already linked to the current OAuth provider. Preserve the existing invite-check
behavior for new OAuth users with matching emails, using the
provider/account-linking context available around this branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 02d04c6c-11ae-4514-b33a-5847d8fe9655
📒 Files selected for processing (6)
apps/docs/self-hosting/overview.mdxapps/docs/self-hosting/railway.mdxapps/web/src/server/auth.integration.test.tsapps/web/src/server/auth.tsapps/web/src/server/auth.unit.test.tsapps/web/src/test/setup/setup-env.ts
15133ea to
60c8f0b
Compare
Entire-Checkpoint: 9d403c1dae5f
60c8f0b to
78ad751
Compare
Summary
Email addresses: Read-onlypermission required for invitation matchingRoot cause
GitHub Apps without the
Email addresses: Read-onlyaccount permission return no email for users whose address is private. The self-hosted registration policy added in 1.9.5 rejected a missing email before checking whether the OAuth account was already linked or whether the installation had no users yet. That caused both upgraded installations and fresh installations to redirect toAccessDenied.Impact
Existing self-hosted GitHub users can sign in again, and a fresh instance can bootstrap its owner even if GitHub omits the email. The invitation-only policy remains enforced for every later account.
Verification
pnpm --filter=web exec vitest run -c vitest.unit.config.ts src/server/auth.unit.test.ts— 14 passedAccessDeniedwith a temporary NextAuth HTTP callback harness and the exact no-email GitHub responsepnpm --filter=web exec tsc --noEmit --pretty falseNo application build or database schema migration is required.
Fixes #434
Summary by CodeRabbit