← Node.js & Express learning path
Node.js & Express · Module 9 of 10

Authentication and security

Protect APIs with hashed passwords, JWTs and secure settings.

📖 Key ideas

  1. Hash passwords with bcrypt; never store plain text.
  2. JWT: sign a token on login, verify it on each request.
  3. Send tokens in the Authorization: Bearer header or httpOnly cookie.
  4. Use HTTPS, helmet, CORS rules and rate limits.
  5. Validate every input and keep dependencies updated.
💡 Real-life example: A JWT is a wristband at a concert: shown at each door, checked quickly without calling the box office.
bcryptPassword hashing library
JWTSigned token proving identity
Bearer tokenToken sent in Authorization header
httpOnly cookieCookie JavaScript cannot read