Repository navigation
feat: move sign-in to @convex-dev/auth 2.0 - #47
Merged
Merged
Conversation
Sign-in now runs on @convex-dev/auth 2.0 components: sessions and refresh tokens in the core component, GitHub accounts in authGithub, tokens signed by the deployment. - Gitdog keeps the GitHub account id on its own users table; every lookup that read authAccounts now reads users.githubAccountId. - createUserFromGithub returns the existing user for a known GitHub id, and until migrateToAuthV2 has run it also links users from the 0.0.x authAccounts table, so nobody gets a second, empty account. - users/migrations:migrateToAuthV2 copies each GitHub account onto its user and deletes the 0.0.x auth rows; the legacy tables stay defined until it has run in production. - One-hour access tokens, as before, so GITDOG_TOKEN automation still works. - The OpenID discovery and JWKS paths 0.0.x served stay, backed by the workload keys Anthropic federation verifies. - Web: the consent page signs in with useSignInWithGithub. - CLI 0.5.0: start/complete sign-in, refreshSession and signOut; the login listener uses one of five fixed loopback ports the server allows. - Tests sign in through real 2.0 sessions (test/helpers/auth.ts); new tests cover the user callbacks and the migration, including a sign-in before it.
|
Visit the preview URL for this PR (updated for commit b99cd6c): https://codeyou-df251--pr47-feat-convex-auth-2-mjqosgaj.web.app (expires Fri, 27 Nov 2026 13:32:03 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 844dad9c62537d028cabc21008e4e2e4031ce4e5 |
hyochan
added a commit
that referenced
this pull request
Nov 20, 2026
Follow-up to #47. Production ran `users/migrations:migrateToAuthV2` on 2026-11-20: both users have `githubAccountId` and all six 0.0.x auth tables are empty (checked again before this PR). - Drop `legacyAuthTables` from the schema (verified on the dev deployment: Convex removes the empty tables' indexes). - Delete `convex/users/migrations.ts` and the `authAccounts` fallback in `createUserFromGithub`; the remaining callback tests move to `test/convex/users/githubSignIn.test.ts`. - `test:dev` no longer lists the old tables in its cleanup. Checks: lint, typecheck, prettier, build, `bun run test` (2102 passed), `check:api`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hyochan
added a commit
that referenced
this pull request
Nov 20, 2026
## Summary Follow-ups found reviewing today's auth 2.0 work (#46, #47, #48) and own-key cost UI (#45). - **Connect page**: after 2.0, installation recovery reports `reauth_required` whenever no fresh attestation exists, so a brand-new user saw "Finishing GitHub connection" instead of Install. Users without an installation now see Install, with "Already installed? Verify GitHub access" as a secondary action. The verification screen is shown only while an installation callback is pending. Screen choice moved into `resolveConnectScreen` with a table test. - **Usage**: the own-key section said reviews run on Gitdog tokens whenever no key worked, but saved keys never fall back. It now distinguishes no key / no working key / temporary outage. The page waits for own-key cost before rendering. - **Consent page**: shows why a GitHub sign-in failed (`useOauth().flowError`). - **CLI**: `github verify` reuses `validateAuthRedirect` (also handles a missing URL); install hints mention `github verify` before `github recover`. - **Smaller**: `getTicketUsage` and recent own-key runs respect `githubLifecycleOnly`; long-context price note in the model picker; per-provider "this period" wording; shared `actionTypeLabel`; screen-reader request count on the usage chip; unused `repositories[].actions` removed. - **Docs**: `getAuthUserId` import path, CLI fixed ports, verify-access architecture line, `CUSTOM_AUTH_SITE_URL` comment. - **Tests**: session auth rejects a bare user-id subject and a revoked session; sign-in redirect allow/deny at the mutation; CLI port fallback and all-ports-busy; consent flow errors. `CONVEX_CLOUD_URL` moved to test setup. ## Verification `bun run lint`, `typecheck`, `build`, `format:check`, `check:api`, `typecheck:cli`, `test:cli` (118 pass), `vitest run` (2124 pass). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Summary
Moves sign-in from
@convex-dev/auth0.0.98 to 2.0.0 (replaces Dependabot's #44, which only bumped the version). In 2.0 auth is a set of Convex components: the coreauthcomponent holds sessions and refresh tokens and the deployment signs the tokens;authGithubholds GitHub accounts and serves the OAuth callback at<CONVEX_SITE_URL>/oauth/github/callback.Do not merge until the cutover below is scheduled. Merging deploys, which signs every client out.
Changes
Backend
convex/convex.config.tsmountsauthandauthGithub(GitHub client id/secret bound from the app env);convex/auth.config.tsusesconvexAuthProvider().convex/auth.ts:setupConvexAuthwith one-hour access tokens (as before, soGITDOG_TOKENautomation keeps working) andsetupGithubwith redirects allowed only toSITE_URLand the CLI's five fixed loopback ports.usersis now an app-defined table withgithubAccountId.createUserFromGithubreturns the user who already has that GitHub id, and while the 0.0.x tables exist it also links a user fromauthAccounts, so a sign-in between deploy and migration never creates a second, empty account.updateUserFromGithubrefreshes the profile and refuses a changed GitHub id.convex/users/githubAccount.tsreplaces every directauthAccountsread (installation attestation freshness, invitations, webhook actor and legal lookups).users/migrations:migrateToAuthV2: copies each GitHub account onto its user, then deletes all 0.0.x auth rows; batched and idempotent, and it stops without deleting if a GitHub id is claimed twice.convex/_utils/auth.tswraps 2.0'sgetAuthUserIdso actions typecheck./.well-known/openid-configurationand/.well-known/jwks.jsonpaths 0.0.x served stay, now backed by the workload keys Anthropic federation verifies (same key as/ai/workload/jwks.json).JWT_PRIVATE_KEY/JWKSstay for federation only.Web:
ConvexAuthProvidergetsapi.auth; the consent page signs in withuseSignInWithGithuband an absolute same-originredirectTo.CLI 0.5.0:
startSignInWithGithub/completeSignInWithGithub,refreshSession,signOut(by refresh token, no refresh first); the login listener tries ports 41721–41725 (the server allows exactly these) and only follows GitHub's authorize page. Installed CLIs needloginagain after cutover.Tests:
test/helpers/auth.tssigns test users in through a real 2.0 session (166 call sites converted); new tests for the user callbacks, the migration and a sign-in that lands before it.bun run test:devmints sessions through the core component.Rehearsed on dev
Deployed to
fortunate-chihuahua-679, ranmigrateToAuthV2(linked GitHub 27461460 to its user, deleted 12 old rows), signed in for real with the new CLI ("Signed in as hyochan"): the GitHub component linked the account to the existing user (user count unchanged at 22), an authenticated call worked, and logout revoked the session. The discovery routes serve the keyed workload JWKS.Cutover checklist (production)
https://calm-hippopotamus-56.convex.site/oauth/github/callbackto thegitdogaiGitHub App redirect URIs (keep the existing ones).bunx convex run --prod users/migrations:migrateToAuthV2untildoneis true.legacyAuthTablesandusers/migrations.ts, remove/api/auth/callback/githubfrom the GitHub Apps, close chore(deps): bump @convex-dev/auth from 0.0.98 to 2.0.0 #44.Checks
bun run lint,bun run typecheck,prettier --check .,bun run build,bun run test(2105 passed),bun run check:api,bun run test:cli(116 passed). An independent security review found no account-takeover or open-redirect paths; its findings (pre-migration sign-in duplicating a user, federation discovery paths, CLI version,test:dev, docs) are fixed.🤖 Generated with Claude Code