# Authentication Fundamentals and Password Storage

> Understand identity, credentials and password hashing, and implement signup, login, reset and email verification safely. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/auth-fundamentals
Last updated: 2026-11-28

Understand identity, credentials and password hashing, and implement signup, login, reset and email verification safely.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Error Handling, Validation and API Hardening](https://www.internhack.in/roadmaps/tracks/full-stack/api-errors-and-validation), [Relational Data Modelling in PostgreSQL](https://www.internhack.in/roadmaps/tracks/full-stack/postgres-data-modeling)

**Authentication** answers "who are you?". **Authorization** answers "what may you do?". Mixing them up causes many real breaches.

### Passwords done right

- Never store passwords in plain text or with fast hashes like MD5 or SHA-256.
- Use a slow, salted algorithm built for passwords: **argon2id** (preferred) or **bcrypt**.
- Enforce a sensible minimum length, allow long passphrases, and check against known breached passwords if you can.

### The flows you must build

- **Signup** with email verification (a signed, expiring link or an OTP).
- **Login** with the same generic error for wrong email or wrong password, so attackers cannot discover registered emails.
- **Password reset** with single-use, short-lived tokens stored hashed in the database.
- **Rate limiting and lockouts** on login and OTP endpoints.

### Beyond passwords

Magic links, phone OTP (common in Indian apps), passkeys and social login reduce password risk. Multi-factor authentication matters for admin accounts.

### Pitfalls

- Rolling your own crypto or token format.
- Reset tokens that never expire or can be reused.
- Logging request bodies that contain passwords or OTPs.

You are ready to move on when you can explain why bcrypt or argon2 beats SHA-256 for passwords and sketch secure signup, login and reset flows end to end.

## Key concepts

- **Authentication vs authorization**
- **Password hashing: argon2 and bcrypt**
- **Signup and email verification**
- **Login and generic errors**
- **Password reset tokens**
- **Rate limiting login and OTP**
- **Passkeys and MFA**

## Mini project

Implement email and password signup, login and password reset in your API with argon2 or bcrypt, hashed single-use reset tokens that expire in 15 minutes, and rate limiting on login.

## Check yourself

Why should a login form say 'invalid email or password' instead of 'no account with this email'?

## Free resources

- [OWASP Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) (OWASP)
- [OWASP Authentication Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html) (OWASP)
- [The Copenhagen Book](https://thecopenhagenbook.com/) (The Copenhagen Book)

Previous: [Caching with Redis](https://www.internhack.in/roadmaps/tracks/full-stack/redis-caching) · Next: [Sessions, Cookies and JWTs](https://www.internhack.in/roadmaps/tracks/full-stack/sessions-vs-jwt)

## More in Authentication, Authorization and Security

- [Authentication Fundamentals and Password Storage](https://www.internhack.in/roadmaps/tracks/full-stack/auth-fundamentals)
- [Sessions, Cookies and JWTs](https://www.internhack.in/roadmaps/tracks/full-stack/sessions-vs-jwt)
- [OAuth 2.0, OpenID Connect and Social Login](https://www.internhack.in/roadmaps/tracks/full-stack/oauth-and-social-login)
- [Auth with Auth.js (NextAuth)](https://www.internhack.in/roadmaps/tracks/full-stack/authjs)
- [Auth with a Hosted Provider (Clerk)](https://www.internhack.in/roadmaps/tracks/full-stack/clerk)
- [Authorization and Access Control](https://www.internhack.in/roadmaps/tracks/full-stack/authorization-rbac)
- [Web Security Essentials](https://www.internhack.in/roadmaps/tracks/full-stack/web-security)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
