Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
DevSecOps Foundations  ›  Lesson

Authentication and Authorization

Authentication 12 minAuthentication proves who a user or service is, and authorization decides what that proven identity is allowed to do, checked on the server every time.

Authentication and Authorization

A courier logs into Tiffin to see today's deliveries. Then, out of curiosity, they type /admin/revenue into the address bar. The login worked, so should the page open? No. Logging in and being allowed are two separate questions, and mixing them up is one of the most common holes in real software.

The rule

Authentication asks who you are; authorization asks what you may do.

Authentication (authn) proves identity. The user or service presents evidence, and the system checks it. Evidence comes in three kinds of factor:

  • something you know: a password or PIN
  • something you have: a phone app code or a hardware key
  • something you are: a fingerprint or face

Multi-factor authentication (MFA) needs factors of different kinds. A password plus a phone code is MFA; two passwords are not.

Authorization (authz) happens after identity is known. It compares that identity's roles or permissions with the action requested. The courier is authenticated, but not authorized for revenue reports.

401 Unauthorized  → we don't know who you are (authentication failed or missing)
403 Forbidden     → we know who you are, and you may not do this (authorization failed)

Yes, the name "401 Unauthorized" is historically confusing. It really means "unauthenticated".

Machines need both too. Tiffin's deploy job authenticates to the cloud with a credential, and is authorized to update one service. Pipelines are identities, and they deserve the same care as people.

The shortcut

Picture a hotel: the front desk checks your ID (authentication) and hands you a key card that opens only your room (authorization). Every request to Tiffin's server must pass both, in that order, on the server.

The courier and the revenue pageStep 1 of 4
  1. Who is asking?

    The request carries the courier's session token. The server verifies it: authenticated as courier Ravi.

The trap: checking permissions only in the user interface. Anyone can send a request directly, so authorization must be enforced by the server for every request.

Drills

Answer fast — trust the rule.

quick drill

A user types the correct password and then approves a prompt on their phone. What is this?

quick drill

A logged-in customer requests another customer's order and is refused. Which status code fits best?

quick drill

Which of these is an authorization decision?

quick drill

Tiffin hides the "Refund" button from non-managers. What is still missing?

Remember

  • Authentication asks who you are; authorization asks what you may do.
  • Front desk checks ID, key card opens one room: both, in order, on the server.
  • Pipelines and services are identities too; authenticate and authorize them like people.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWho are you, and what may you do?

Tiffin's pipeline has a deploy job that uses a long-lived admin token able to change anything in the cloud account. Explain the difference between authentication and authorization using this job, and describe how you would improve both.