Skip to content

feat(auth): add shared Google sign-in flow - #105

Merged
rdlabo merged 2 commits into
mainfrom
feat/social-auth-kit
Sep 7, 2026
Merged

feat(auth): add shared Google sign-in flow#105
rdlabo merged 2 commits into
mainfrom
feat/social-auth-kit

Conversation

@rdlabo

@rdlabo rdlabo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an isolated Firebase Google auth entry point for web popup and native Capacitor flows
  • support new, link, reauthenticate, credential/password-link, and best-effort logout modes
  • move shared behavior and regression coverage into the Kit while keeping app HTTP/UI effects injectable

Verification

  • npm run lint
  • npm test -- --watch=false --project kit
  • npm run prebuild:kit

Consumer PRs will follow after an immutable beta package is available.


Devin Review

@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 found 2 potential issues.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

user = requireUser(auth);
const result = await reauthenticateWithPopup(user, provider);
idToken = GoogleAuthProvider.credentialFromResult(result)?.idToken ?? '';
await options.success?.({ idToken, mode: options.mode, user });

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.

🔴 認証中に利用者が変わると別のアカウントを成功扱いする

再認証した利用者は、現在の利用者との再確認なしに成功通知される(success)ため、認証中にアカウントが変わると別の利用者の処理を成功扱いします。
Impact: アプリは現在ログイン中でない利用者の再認証やパスワード追加を完了したと誤認します。

早期 return が利用者の整合性検査を迂回する仕組み

reauthenticatecredential は Web の 74、81 行目、ネイティブの 100、105 行目から早期 return します。そのため通常の newlink が通る auth.currentUser の検査を実行しません。

ポップアップ表示中やネイティブ認証中にサインアウト、別タブの認証変更、別のログイン処理が発生すると、取得済みの user に対する再認証やパスワード追加は続行されます。その後は現在の利用者を確認せず、成功フックと { status: true } を返します。特に credential では、現在表示中のセッションとは異なるアカウントへパスワードを追加し得ます。

Prompt for agents
projects/kit/auth-firebase/google/src/kit-google.ts の kitGoogleLogin で、reauthenticate と credential の Web・ネイティブ各分岐が早期 return する前に、処理対象の user が auth.currentUser と同一か確認してください。非同期の再認証後、パスワードリンク後、success フック前後のどこで整合性を保証するかを整理し、通常の new/link 分岐と同じ契約にしてください。認証待機中に currentUser が null または別 User へ変わるテストも追加してください。
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

修正しました。全モードで非同期処理後・success前後に同一の Firebase currentUser を検証し、credential中にcurrentUserが変わった場合はpassword linkを実行しない回帰テストも追加しています(f5f5c26)。

Comment thread projects/kit/package.json
"@capacitor-community/in-app-review": ">=7.0.0 <9.0.0",
"@capacitor-community/facebook-login": ">=8.0.0 <9.0.0",
"@capacitor-community/apple-sign-in": "*",
"@capawesome/capacitor-google-sign-in": "^0.1.4",

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.

🟡 Capacitor 7 の対応アプリでは Google ログインを導入できない

Google ログイン依存関係は Capacitor 8 専用版に固定されている(@capawesome/capacitor-google-sign-in)ため、対応対象の Capacitor 7 アプリでは依存関係を解決できません。
Impact: Capacitor 7 の利用者は新しい Google ログイン機能をインストールできません。

宣言された対応範囲とプラグイン要件の不一致

Kit は @capacitor/core>=7.0.0 <9.0.0 と宣言し、README も Capacitor 7.x–8.x を対応対象としています。一方、追加されたプラグイン 0.1.x の公開パッケージメタデータは @capacitor/core >=8.0.0 を peer dependency としています。

この peer は optional なので Google 機能を使わない導入には影響しません。しかし Capacitor 7 の利用者が /auth-firebase/google 用にプラグインを追加すると、npm の peer dependency が衝突します。

Prompt for agents
projects/kit/package.json と README の対応範囲を、Google Sign-In プラグインの @capacitor/core >=8 要件と整合させてください。Capacitor 7 対応版のプラグインを提供できない場合は、Google の secondary entry point が Capacitor 8 専用であることをパッケージ契約と利用文書で明示し、Capacitor 7 全体対応と誤認されない構成にしてください。
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Google secondary entry pointがCapacitor 8専用であることをREADMEへ明記しました。プラグインはoptional peerのため、Capacitor 7利用者のcore Kit・他entry point導入は引き続き可能です(f5f5c26)。

@rdlabo
rdlabo merged commit 55308d6 into main Sep 7, 2026
14 checks passed
@rdlabo
rdlabo deleted the feat/social-auth-kit branch September 7, 2026 15:21
@rdlabo

rdlabo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

/beta

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

npm beta packages published

CI passed for the merge commit 55308d6acf67. Install the immutable package set with:

npm install @rdlabo/ionic-angular-kit@22.0.1-beta.pr105.sha55308d6acf67 @rdlabo/ionic-angular-photo-editor@22.0.1-beta.pr105.sha55308d6acf67 @rdlabo/ionic-angular-scroll-header@22.0.1-beta.pr105.sha55308d6acf67 @rdlabo/ngx-cdk-scroll-strategies@22.0.1-beta.pr105.sha55308d6acf67

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