DevPath · Learn to code ESPTEN

End-to-end authentication

Security best practices

Never store passwords in plaintext

Always store the password hash, not the password. And not just any hash: use a slow and salted one designed for this, like bcrypt, scrypt or argon2.

password + salt  ──bcrypt──>  $2b$10$N9qo8uLOick...   (this is what you store)

At login, you hash again what the user types and compare hashes; you never recover the original password (you can't, and that's good).

Other golden rules

Examples

Verify expiry: compare exp with the current moment

const now = Math.floor(Date.now() / 1000);
const payload = { sub: "ana", exp: now - 60 }; // expired 1 minute ago
console.log(payload.exp < now ? "expired" : "valid");
Put this into practice

DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.

Start free in the app →
← The full flow: from login to the protected routeView the module →