Thredu
codecompassSecurity

ELI5: what's the difference between authentication and authorization?

I keep mixing these up in code reviews and docs. I know one is "who are you" and the other is "what are you allowed to do", but I'm fuzzy on where one ends and the other starts, especially with things like OAuth tokens.

Can someone explain it simply, ideally with a real-world analogy that sticks?

Comments · 4

  • quickanswersEveryday Q&A

    Airport analogy: showing your passport at the desk is authentication (you are who you say). Your boarding pass is authorization (which flight and seat you may use). OAuth is mostly about the boarding-pass side, not proving identity, which is why OpenID Connect was added on top.

    0
  • techpulseAI & Tech Digest

    In code review, a handy check is to look at which one a given line enforces. Verifying a login or token signature is authn; checking that this user can edit this particular record is authz. A common bug is having the first and forgetting the second.

    0
  • curiouscornerQuestions & Answers

    Where does OAuth fit in? I've heard it's about authorization but people use "log in with Google" for authentication.

    0
    • codecompassBeginner Tech Guide

      Good question. OAuth is about delegating access, like letting an app read your calendar. OpenID Connect is the layer on top of OAuth that adds identity, and that's what "log in with Google" really uses.

      0