Repository navigation
Conversation
A unique constraint over every row let anyone attach a stranger's number to an account of their own without proving it, so its owner could never add it, and the 409 from /registration/phone told any signed-in caller which numbers were registered. Only verified numbers are unique now; a code goes out either way and a number another account has verified is refused at verification.
…bers as taken Import matched unverified holders as owners, an admin update that hit the verified-phone index answered 500, and without the 409 nothing bounded how many accounts could send codes to one number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #600 (L-API-3).
A unique constraint over every
users.phonerow let anyone attach a stranger's number to an account of their own without proving it, and the number's owner could then never add it. The 409 fromPOST /registration/phonealso told any signed-in caller which numbers were registered.What changes
20261204130000-unique-verified-phone: the index is created before the constraint is dropped, and existing data already satisfies it.users_verified_phone_keyonphoneWHERE phone_verified = true.users_phone_key.POST /registration/registerdrops a supplied phone only when another account has verified it.POST /registration/phonesends a code whatever account holds the number. It is now also limited per destination number (otpPhoneTargetLimiter, at four timesflow_rate_limits.otp.perIdentity), so many accounts cannot each send codes to one phone.POST /registration/phone/verifyandPOST /otp/verify-phone-otpanswer 409Phone number in usewhen another account has already verified the number. The index raises it as a unique violation when the phone is marked verified. This is the only point where it shows, and only to someone who has just proven they hold the phone.PATCH /admin/users/{userId}answers 409 instead of 500 when the update hits the email or verified-phone uniqueness.Sign-in by phone, login phone OTP and account recovery already read only verified phones.
Contract (minor changeset, breaking)
POST /registration/phoneno longer answers 409.POST /registration/phone/verifyandPOST /otp/verify-phone-otpcan answer 409.phonein webhook and login hook payloads may now be an unverified number that another account also holds. Integrations that key on it should use the user id.Ripple survey (read-only):
seamless-auth-serverforwards these routes through its manifest passthrough and does not branch on their status codes.seamless-auth-jstreats any non-2xx fromverify-phone-otpas an error result./registration/phone.Tests
tests/postgres/verifiedPhoneUnique.spec.ts): unverified duplicates are allowed, the owner can verify a number a stranger attached, and a second verified holder is refused. The migration was run up, down and up against a scratch database./registration/phoneanswers alike, the 409 at both verify routes, the per-number limiter, the import lookup, and the admin 409.