What it is
Signup creates an account; login proves control of its credential. Store a password verifier produced by a dedicated password-hashing function, not a recoverable password. A salt makes independently stored verifiers different even when users choose the same password.
Why you need it
If account data is exposed, plaintext passwords can be used immediately. Expensive password verification increases the cost of offline guessing, though it cannot make weak passwords impossible to guess.
How it works
- Validate the signup input and normalize the account identifier under a defined policy.
- Generate a verifier with a maintained password-hashing library and a fresh salt.
- Store the verifier and account record under an identifier uniqueness constraint.
- At login, use the library’s verification function, then create a new authenticated session.
Store a verifier, not the submitted password
// Library API names are illustrative.
verifier = passwordLibrary.hash(password)
users.insert({ email, verifier })
user = users.findByEmail(email)
valid = passwordLibrary.verify(user.verifier, submittedPassword)
if not valid: return genericLoginFailure
return createSession(user.id)Use a maintained library with reviewed parameters; the complete handler also needs missing-account handling, abuse controls, and safe error behavior. The downloadable local lab demonstrates salted scrypt verification without an HTTP server.
Download the file and run node backend-auth.mjs with Node.js 22 or newer. It tests an in-memory auth model; it is not a production login server.
Good practices and why
- Use an appropriate password-hashing scheme such as Argon2id; select parameters for the deployment with security guidance and measurement.
- Rate-limit credential attempts, support stronger authentication where needed, and avoid logging submitted passwords.
Common mistakes
- Using a fast general-purpose hash alone for password storage.
- Assuming password reset should reveal the old password; reset should establish a new credential through a verified recovery flow.
Try it yourself
Run the local authentication lab. Inspect how the stored salt and verifier differ from the password, then trace the wrong-password case.
What a successful result looks like
You can explain why the app verifies a password without decrypting it, and a wrong password cannot create a session.
0 / 6000 characters · Saved on this device. Do not include passwords or private data.
Check your understanding
Answer the understanding check correctly to record exercise completion.
Related interview practice
These scenarios add constraints and follow-up questions to the concepts you just learned.
Further reading
- OWASP: authentication ↗
- OWASP: password storage ↗
- OWASP: session management ↗
- MDN: Set-Cookie ↗
- IETF: JWT best current practices ↗
Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.