Authentication vs Authorization, What's the Difference?

A simple explanation of the difference between authentication (AuthN) and authorization (AuthZ), with simple analogies and examples.

4 min read
authentication

Ever walked into an office, showed your ID, and still couldn't get into the CEO office? Well congrats, you've experienced authentication and authorization in real life!

What is Authentication ( AuthN )?

Authentication is the process of proving who you are.

It's like showing your ID when you enter a office building. A security will check your ID to confirm your identity before letting you in.

There are several common methods of authentication:

  • Passwords: The most common method. You enter a secret word or phrase that only you know.
  • Biometrics: Using your unique physical characteristics, like fingerprints or facial recognition.
  • OAuth: A protocol that allows you to use your credentials from one service (like Google or Facebook) to log into another service without sharing your password.

And many more, which will be covered in future posts.

So, authentication is all about verifying your identity. But here's the catch: just because you're logged in doesn't mean you can do anything you want. The system still needs to decide what you're allowed to do. That's where authorization comes in.

AuthN AuthZ meme, https://us-west-2.graphassets.com/AuGrs0mztRH6ldTYKJkSAz/resize=width:775,height:500/i8Uc3TWSi7p6UjAGGvoA

What is Authorization ( AuthZ )?

Authorization is the process of determining what you are allowed to do.

Continuing with the office analogy, once you're inside the building, it doesn't mean you can go into every room. You need a permission to enter certain areas, like only manager can access the CEO office, and etc.

Authorization is checking your permissions and roles to see what actions you can perform and what resources you can access.

Key Differences Between AuthN and AuthZ

AspectAuthentication (AuthN)Authorization (AuthZ)
PurposeVerify identityDetermine access rights
Question Answered"Who are you?""What can you do?"
ProcessInvolves credentials (passwords, biometrics, etc.)Involves permissions and role
TimingHappens before authorizationHappens after authentication
ExampleLogging in with a username and passwordAccessing a restricted file or admin panel

Why Both Are Important

Both authentication and authorization are crucial for maintaining security in any system.

  • Without authentication, anyone could access the system, leading to potential data breaches and unauthorized access.
  • Without authorization, even authenticated users could access sensitive information or perform actions they shouldn't be allowed to.

Together, they ensure that only the right people can access the right resources.

Conclusion

In summary:

  • Authentication (AuthN) is about verifying who you are.
  • Authorization (AuthZ) is about determining what you can do.

What's Next?

You might be wondering, "How authentication and authorization work in real-world applications?". In the next post, we'll explore how these concepts are implemented in web applications, including common protocols and best practices.

Reynaldi Neo Ramadhani

Reynaldi Neo Ramadhani

Software developer focused on creating clean, user-friendly experiences. I write about web development, programming, and technology.

Related Articles