Repository navigation
feat(auth): hashed single-use verification codes, no stub users before verification - #395
Merged
Merged
Conversation
…e verification Phase 1 of the SMS guard on the FleetOps side (needs core-api with the hashed-code APIs, fleetbase/core-api#307): - The customer API no longer persists a User for an identity that merely asked for a creation code; the code's subject is the existing user or an unsaved one. A users row per unverified identity was a way to fill the table from a leaked credential. - Every SMS code the driver and customer APIs send is issued hashed (HMAC on the row, 10 minute expiry, plain code only in the message). - One verify-and-consume path: create, verify-code, and the password resets check the submitted code against the live codes for the identity or user, newest first, lock a code after five wrong guesses, and mark the matching one used. Plaintext rows written before this verify the same way. - The public tracking page consumes a verified code instead of deleting it, so the row stays for the ledger.
4 tasks done
Member
Author
|
Follow-up: the API endpoints here still flattened an |
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.
What
Phase 1 of the SMS guard on the FleetOps side, on top of #393 (phase 0). Pairs with fleetbase/core-api#307 and needs the core release that carries it.
POST v1/customers/request-creation-codeno longer persists aUserfor an identity that merely asked for a code. The code's subject is the existing user when there is one, otherwise an unsaved user carrying the name and contact details the message needs. A users row per unverified identity was an enumeration and pollution vector behind a leaked credential.login-with-sms,request-creation-code,forgot-password) is issued with core'shashedoption: HMAC on the row, 10 minute expiry, plain code only in the message.customers/(create),customers/verify-code,customers/reset-password,drivers/verify-codeanddrivers/reset-passwordcheck the submitted code against the live codes for the identity or user, newest first, lock a code after five wrong guesses, and mark the matching one used. Codes written before this change (plaintext) verify the same way; a used code never verifies again.Compatibility
API payloads are unchanged. Requires a core with
VerificationCode::consume()and theSTATUS_*constants (fleetbase/core-api#307); the composer constraint is left for the release that carries it.Merge order
Based on
feature/sms-guardso the diff shows only phase 1. Before merging #393, retarget this PR torelease/v0.6.72; otherwise GitHub closes it when the base branch is deleted.Tests
Contract tests updated for the removed stub user and the spent-code semantics; a new seam test covers a wrong guess counting against live codes, the right code being used up, and a used code refusing to verify again; the tracking-access test asserts the used row stays. Not run locally: the package's Pest bootstrap does not start under this machine's PHP 8.4. CI is red for a pre-existing reason (Composer cannot resolve
core-api ^1.6.69until it is tagged); once that is green, the coverage gate will show whether any branch here is uncovered.Follow-ups
Per-identity attempt lockout on the API check endpoints (the storefront has it); hashed email codes.