mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
fix(auth): link single sign-on to an existing account only after its own sign-in
The SSO callback bound a verified provider email to the local account with the same address on the spot. The local address is not verified: anyone could register with it, or type it into their profile, and the SSO user then landed in an account the other person still held the password to. The callback now links nothing. It records the link it would make in a sealed, ten-minute, HttpOnly cookie and sends the browser to the sign-in page, and the link is made only when that browser then signs in to that same account with its password (and second factor) or passkey. Under an SSO-only policy the password form opens for exactly that account. The native sign-in answers oidc_link_required; the link is confirmed once on the web. Moving an account to a new email address now also needs a fresh proof: a sign-in or second factor in the last five minutes, or the current password sent alongside the change. Without it the address is left as it was and reported in rejectedFields; the rest of the save still lands.
This commit is contained in:
1 parent
7b5bc130d8
commit
8da7583ec6
27 files changed
+878
-76
No files matched your search
@@ -78,6 +78,10 @@ const REJECTION_REASON_KEYS: Record<string, string> = {
|
||||
// still lands. Without an entry it would fall back to "check it and try
|
||||
// again", which is wrong — the value was fine, the timing was not.
|
||||
rate_limited: "settings.profileRejection.rateLimited",
|
||||
// Not Zod codes either: a new email address asks for a fresh proof, and
|
||||
// these say whether none was given or the one given was wrong.
|
||||
reproof_required: "settings.profileRejection.reproofRequired",
|
||||
reproof_failed: "settings.profileRejection.reproofFailed",
|
||||
too_big: "settings.profileRejection.tooBig",
|
||||
too_small: "settings.profileRejection.tooSmall",
|
||||
invalid_value: "settings.profileRejection.invalidValue",
|
||||
|
||||
Reference in new issue
Block a user