Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Authentication and authorization

Storing & validating passwords

Here is a summary of the video transcript:

  • Password Hashing with Salt

    A function is implemented to generate a cryptographically secure random salt for each password. This ensures that identical passwords produce different hashes, preventing rainbow table attacks and improving overall security.

  • Argon2id-Based Hashing Strategy

    Passwords are combined with a secret pepper from environment variables and hashed using Argon2id. Specific parameters (iterations, memory usage, parallelism, key length) are chosen to balance security and performance based on recommended practices.

  • Encoding and Storage Format

    The resulting hash and salt are base64-encoded and stored together as a colon-separated string. This allows both values to be persisted securely and later retrieved for verification.

  • Password Validation Mechanism

    During authentication, the stored value is split to extract the hash and salt. The provided password is re-hashed using the original salt, and the results are compared using a constant-time comparison function to prevent timing attacks.

  • User Creation with Hashed Passwords

    When creating a user, the plaintext password is replaced with the hashed version before being stored in the database. The pepper is configured via environment variables and kept secret from external systems.

  • Security Considerations and Next Steps

    The approach protects against common attacks and minimizes damage in case of database breaches. Future improvements include adding middleware, rate limiting, login protection, and access control for admin routes.