Gate point before a verify creates a user

Aperta
#202 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start in the verify flow around authenticateWithIdentifier, following the calls to userStore.create and identityStore.create, then read InitiateGate.onVerified and checkVerifiedGate. Decide between the onBeforeCreateUser hook and an onInitiate silentRefuse decision before writing anything. Done means the gate is consulted before any user or identity row is written, a refused correct code returns the same error as a wrong one without clearing the auth_challenge cookie, and isNewUser is documented.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

InitiateGate.onVerified runs after authenticateWithIdentifier has already called userStore.create and identityStore.create. An app that answers every initiate the same way, so its form doesn't reveal who has an account, still gets a live code stored for an address it won't serve. If someone guesses that code, the account is created before the gate is asked. To refuse it, the app has to delete rows the library just wrote. Two verifies of the same code can also both get past the challenge and reach that sequence together, so the app can't use "I inserted this row" to mean "this account is new". It needs its own approval mark.

Ask, either of:

  1. A hook such as gate.onBeforeCreateUser({ provider, identifier, request }), called in authenticateWithIdentifier before userStore.create. Its { error } fails the verify like a bad code.
  2. An onInitiate decision such as "silentRefuse": no challenge is stored and no email is sent, but the answer is the same as for an accepted initiate (status, redirect, and a challenge cookie of the same shape).

Also: when onVerified answers { error }, send that error without the provider's cookie that clears auth_challenge (checkVerifiedGate adds it today). If the cookie is cleared, a refused correct code doesn't answer like a wrong one: the next post from that browser gets "Verification not found" instead of "Incorrect code", which shows the guess was right and the address isn't served.

Also worth documenting: isNewUser means "no identity existed", not "the user row is new", which matters for a user store that upserts.

Found while building invites in activescott/four-in-a-row (security reviews on activescott/four-in-a-row#42). That app works around this today with an approved_at column that only onVerified sets.

Milestone: Private Beta, because an invite-only app is exactly the case this affects.

Lingua principale
TypeScript
Stelle
0
Fork
2
Merge medio
11g 7h
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di activescott/auth

Tutte le issue di activescott/auth

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.