Course Overview
Locked video preview

Watch for free

Create a free account to watch this video.

Authentication and authorization

Intro to authentication

Here is a summary of the video transcript:

  • Need for Authentication
    The current application allows unrestricted access to the admin page, enabling any user to create or delete articles. Authentication is introduced to restrict administrative actions to authorized users only.

  • Build vs. Third-Party Authentication
    The video challenges the claim that developers should never build their own authentication. It argues that secure authentication is achievable by understanding core principles, and third-party services may introduce cost, lock-in, and limited flexibility.

  • Authentication vs. Authorization
    Authentication verifies a user’s identity (e.g., email and password), while authorization determines what actions a user is allowed to perform. The focus of the implementation is authentication, as only one admin role is required.

  • Password Security Fundamentals
    Passwords must never be stored in plain text. Instead, they should be hashed using a one-way function to prevent recovery of the original password if the database is compromised.

  • Hashing, Salting, and Peppering
    Hashing converts passwords into irreversible values. Salting adds unique random data per user to prevent rainbow table attacks, while peppering adds a global secret stored separately (e.g., in an environment file) for additional security.

  • Argon2ID for Secure Hashing
    The recommended hashing algorithm is Argon2ID, known for being computationally and memory intensive, making brute-force attacks costly. It automatically handles salting and uses constant-time comparisons to mitigate timing attacks.

  • Session Management with Cookies
    After successful authentication, a cookie is created to persist the user’s login state for a defined duration. This avoids repeated logins and enables protected access to admin functionality using middleware.

  • Implementation Steps
    The system requires adding a users table, generating and storing hashed passwords, verifying credentials during login, and issuing authentication cookies. Once complete, only authorized users can access the admin interface.