Skip to content

fix(auth-client): ID トークンに email を求めず、本物の accounts でログインできるようにする - #24

Merged
t1nyb0x merged 1 commit into
developfrom
fix/auth-client-id-token-email
Oct 10, 2026
Merged

t1nyb0x merged 1 commit into
developfrom
fix/auth-client-id-token-email

Conversation

@t1nyb0x

@t1nyb0x t1nyb0x commented Oct 10, 2026

Copy link
Copy Markdown
Member

手元で Prismtone から本物の lumorphia/accounts に「Lumorphia でログイン」したら、callback で Invalid Lumorphia claim string になり、ログインできなかった。

原因

  • lumorphia/accounts (Better Auth 1.7.7 の oauth-provider) は、アクセストークンを出すときは email などの標準の claim を ID トークンに入れず、UserInfo でだけ返す (OIDC Core 5.4)。createIdToken は標準の claim を ID_TOKEN_SCOPE_CLAIM_GUARDS で undefined にし、標準の claim を作る userNormalClaims は UserInfo の応答でだけ使う
  • auth-client 1.1.0 は ID トークンの email と email_verified を必須にしていた (claimString(payload.email))
  • テストの発行元 (このパッケージの provider.test.ts と prismtone の e2e/mock-lumorphia.ts) は ID トークンに email を入れていて、ずれに気づけなかった。accounts の E2E は ID トークンの email を確かめていない

変更

  • ID トークンでの email・email_verified の検査をやめる。UserInfo の email・email_verified の検査 (もとからある) に任せる。ID トークンの署名・issuer・audience・sid・sub・handle・legacy_pending の検査はそのまま
  • テストの発行元を本物と同じ形 (ID トークンに email を入れない) にした。email が無い・email_verified が無い UserInfo を拒むテストに移した

検証

  • テストを本物の形にしてから、ログインが通るはずのテスト 3 件が落ちることを確かめ、直して通した (auth-client 107 件、全体 249 件)
  • lint・typecheck・prettier

公開 (1.1.1) のあとで、prismtone の版を上げ、e2e/mock-lumorphia.ts も ID トークンに email を入れない形にする。

🤖 Generated with Claude Code

lumorphia/accounts (Better Auth 1.7.7 の oauth-provider) は、アクセストークンを出すときは
email などの標準の claim を ID トークンに入れず、UserInfo でだけ返す (OIDC Core 5.4)。
auth-client は ID トークンの email と email_verified を必須にしていたので、本物の accounts を
相手にすると callback で必ず `Invalid Lumorphia claim string` になった。テストの発行元も
ID トークンに email を入れていて、ずれに気づけなかった。

ID トークンでの email の検査をやめ、UserInfo の email・email_verified の検査 (もとからある) に
任せる。テストの発行元は本物と同じく ID トークンに email を入れない形にし、email が無い・
email_verified が無い UserInfo を拒むことを確かめる。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@t1nyb0x
t1nyb0x merged commit 572f60f into develop Oct 10, 2026
3 checks passed
@t1nyb0x
t1nyb0x deleted the fix/auth-client-id-token-email branch October 10, 2026 09:58
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.

1 participant