Skip to content

fix(auth): guard sign-out against newer sessions#38

Merged
rdlabo merged 1 commit into
mainfrom
fix/auth-signout-commit-guard
Jul 25, 2026
Merged

fix(auth): guard sign-out against newer sessions#38
rdlabo merged 1 commit into
mainfrom
fix/auth-signout-commit-guard

Conversation

@rdlabo

@rdlabo rdlabo commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an optional expectedUser identity guard to kitSignOut
  • evaluate the guard after asynchronous before cleanup and immediately before Firebase signOut
  • skip signOut, success, and error when a newer Firebase User object has replaced the expected session
  • preserve the existing two-argument API and lifecycle when no guard is supplied
  • document the denial/re-login use case

Validation

  • npx ng test kit --watch=false (35 files / 491 tests)
  • npm run prebuild:kit
  • npm run lint
  • git diff --check

@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for rdlabo-ionic-angular-library ready!

Name Link
🔨 Latest commit 89eaea5
🔍 Latest deploy log https://app.netlify.com/projects/rdlabo-ionic-angular-library/deploys/6a647975e510f10008eb0717
😎 Deploy Preview https://deploy-preview-38--rdlabo-ionic-angular-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rdlabo rdlabo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

第三者受け入れレビュー(head 89eaea5): APPROVED

前回 tipsys で差し戻した TOCTOU を独立検証しました。

  • expectedUser の identity 照合は async before 完了後、Firebase SDK signOut(auth) の呼び出し直前にあります。照合と SDK 呼び出しの間に await はなく、User A の denial cleanup 中に same UID の別 object User B へ変わった場合、B を対象とする SDK sign-out は開始されません。
  • 再現テストは A と B を同じ UID・別 object とし、before 中に差し替えています。結果は false、SDK signOut 未呼び出し、success/error 未呼び出し、finally 1回で、問題の競合を決定論的に再現しています。
  • options は第3引数で任意のため、従来の kitSignOut(auth, hooks) は source/runtime compatible です。guard 未指定時の SDK delegation、成功、失敗時 error hook の既存テストも維持されています。
  • lifecycle semantics は旧実装と整合しています。before は従来どおり try の前、SDK/signOut と success は try 内、失敗時 error、finally は成功・SDK失敗・expectedUser mismatch で実行されます。mismatch のみ意図的に success/error を発火しません。

ローカル再検証: npx ng test kit --watch=false = 35 files / 491 tests pass、git diff --check clean。ブロッカーはありません。

GitHub の自己承認制約があるため、Approve 状態ではなくレビューコメントとして記録します。

@rdlabo
rdlabo marked this pull request as ready for review July 25, 2026 08:55
@rdlabo
rdlabo merged commit 8564a05 into main Jul 25, 2026
12 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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