0
0
HLDsystem_design~3 mins

Authentication vs authorization in HLD - When to Use Which

Choose your learning style9 modes available
The Big Idea

What if you could stop guessing who someone is and what they can do, and instead have a clear, secure way to check both every time?

The Scenario

Imagine you run a busy office where everyone needs to enter a building and access different rooms. Without a system, you have to check each person's ID and then remember which rooms they can enter. This manual checking slows everything down and causes confusion.

The Problem

Manually verifying who someone is and what they can do is slow and error-prone. People might get access to places they shouldn't, or get denied entry by mistake. It's hard to keep track of permissions and identities separately, leading to security risks and frustration.

The Solution

Authentication and authorization split the job into two clear steps: first, confirm who the person is (authentication), then decide what they are allowed to do (authorization). This separation makes systems faster, safer, and easier to manage.

Before vs After
Before
if user_id == known_id and room in allowed_rooms:
    allow_entry()
After
if authenticate(user_credentials):
    if authorize(user, resource):
        allow_entry()
What It Enables

This clear separation lets systems securely control access at scale, ensuring only the right people do the right things.

Real Life Example

When you log into your email, the system first checks your password (authentication). Then, it decides if you can read emails, send messages, or change settings (authorization).

Key Takeaways

Authentication verifies identity; authorization controls access.

Separating these improves security and clarity.

It helps build scalable, safe systems for many users.