Skip to content

feat(auth): include linked GitHub account id in OAuth id_token - #62

Open
mroderick wants to merge 1 commit into
mainfrom
feature/github-id-id-token
Open

feat(auth): include linked GitHub account id in OAuth id_token#62
mroderick wants to merge 1 commit into
mainfrom
feature/github-id-id-token

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

Summary

Related: codebar/planner#2805.

The planner now matches returning members by the stable GitHub account id when a user's GitHub email differs from their stored planner email (codebar/planner#2806). This change adds that github_id claim to the OAuth id_token so the planner can perform the lookup.

Changes

  • Added src/auth/id-token-claims.js to look up a user's linked GitHub accountId from the Better Auth account table.
  • Configured customIdTokenClaims on the OAuth provider to inject github_id into the id_token.
  • Added integration tests verifying the claim is present for GitHub-linked users and absent for magic-link-only users.

Deployment note

This should be deployed before or alongside codebar/planner#2806. When the claim is absent, the planner falls back to its existing email-based matching.

Post-Deploy Monitoring & Validation

  • Monitor logs for errors from getGithubAccountId after deploy.
  • Verify that planner logins via codebar auth still work.
  • Check that the id_token issued for GitHub-linked users contains a github_id claim.

@mroderick
mroderick force-pushed the feature/github-id-id-token branch from df9a3ce to 83b6160 Compare August 11, 2026 08:40
@mroderick
mroderick marked this pull request as ready for review August 11, 2026 08:45
export async function getGithubAccountId(db, userId) {
const result = await db.query(
'SELECT "accountId" FROM "account" WHERE "userId" = $1 AND "providerId" = $2 LIMIT 1',
[userId, "github"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a fixed ‘github’ value inside the query be… clearer? As opposed to being a second arg?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, since this method is only for github

@olleolleolle olleolleolle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks lovely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants