skip to content

Authentication vs Authorization

Authentication establishes who is calling; authorization decides what that caller may do — and confusing the two is the root of broken access control. Interviewers ask about sessions versus tokens, role and attribute-based models, and why every request must be checked server-side instead of trusting a hidden button.

part ofApplication security & secure codingoverview, primer and where to startread it →
on this pageshow

questions

5

Authentication and authorization are routinely bundled together as 'auth'. Define each precisely, explain why they are kept as separate concerns in a system's design, and name the failure that appears when they are conflated.

level: juniorimportance: must knowfreq 85%

answer

  1. who are you vs what may you do
  2. once per credential vs every request
  3. gateway authenticates, resource owner authorizes
  4. impersonation vs escalation
  5. 401 unauthenticated / 403 unauthorized

basics

~20 s

Authentication establishes who the principal is, from evidence, with some level of confidence. Authorization decides whether that principal may perform this action on this resource, in this context. Conflating them produces 'logged in, therefore allowed' - the most common access-control bug.

solid answer

~50 s

Authentication answers 'who is this' - a claim of identity plus evidence for it, evaluated when credentials are presented, producing a principal and an assurance level. Authorization answers 'may this principal do this' - a decision function over subject, action, resource and context, evaluated on every access. They are separated because they differ on every axis: different inputs (credentials versus domain state), different frequency (once per credential presentation versus once per request), different placement (an edge component can authenticate; only code that knows the resource can authorize), and different failure modes (impersonation versus privilege escalation). The conflation failure is 'authenticated therefore allowed': the system verifies identity carefully and then acts on any request that arrives with a valid session. The mirror failure is treating an authorization construct as identity - a shared service account used by many humans satisfies policy while destroying attribution. Protocols encode the split: HTTP 401 means unauthenticated, HTTP 403 means authenticated but not permitted.

go deeper

for a junior

Give crisp definitions plus one concrete example of each and the 'logged in therefore allowed' failure.

for a middle

Explain the different inputs, lifetimes and placements, and why the decision must be re-made per request.

for a senior

Show where each is enforced in a layered system and how authentication strength and age feed policy.

for a principal

Argue for one identity model and one enforcement point across services, and for making assurance an explicit policy input rather than a flag.

## Precise definitions **Identification** is the claim: 'I am user 42'. It is unverified input. **Authentication** is producing evidence for that claim and evaluating it - something known, something held, something inherent, or a combination - yielding a principal plus an assurance level and a timestamp. **Authorization** is a decision: given a subject, an action, a resource and surrounding context, permit or deny. **Accounting** records what the principal actually did, and depends on authentication being individual rather than shared. ## Why the separation is structural, not pedantic - **Different inputs.** Authentication consumes credentials and identity-provider state. Authorization consumes domain state: who owns this record, which tenant it belongs to, what its lifecycle status is. A component with credentials but no domain knowledge can do the first and cannot do the second. - **Different lifetimes.** Authentication happens at credential presentation and its result ages. Authorization must be re-decided per request, because the world changes between requests: roles are revoked, ownership transfers, an object moves to a locked state. - **Different placement.** A gateway or proxy is a good place to authenticate and a poor place to authorize anything object-level, because it does not know the resource. Function-level rules ('only administrators may call this operation') can sit at the edge; record-level rules must sit where the record is loaded. - **Different failure modes.** Weak authentication yields impersonation - the attacker becomes someone else. Weak authorization yields escalation - the attacker stays themselves and reaches what is not theirs. Different tests, different logs, different fixes. ## The conflation failure in both directions The common direction is treating a valid session as a permit. Everything after the login page assumes the hard part is done, so handlers read an identifier from the request and act. Because the request carried a valid session, logs look normal and nothing alerts. That is the broken-access-control family that consistently tops industry taxonomies. The reverse direction is subtler: using an authorization artefact as identity. A shared service or integration account passes every policy check while making it impossible to say which human did what, and it usually accumulates the union of everyone's permissions. Similarly, deriving identity from a permission ('anyone who can reach this network is staff') collapses the two concerns and inherits the weakest assumption. ## Where identity strength enters the decision Authentication is not a boolean. It has a strength (which factors, how phishing-resistant), an age (how long since the credential was presented), and a binding (how tightly the credential is tied to a channel or device). Note also that the factor categories matter more than the count: two things the user knows are not two factors. A well-designed policy consumes these: a routine read accepts an old session, while changing a payout destination requires a recent, strong re-authentication. That is only expressible if the two concerns are separate values in the system rather than one flag. Everything downstream is also capped by identity proofing at enrolment and by the account-recovery path - a strong login on an account an attacker recovered is a strong lock on a forged identity. ## The one-line invariant Authentication produces a principal with a confidence level; authorization is a decision made per request from server-owned state about that principal. Neither substitutes for the other, and the presence of the first never implies the second.

  • Where in a system should each concern be enforced, and why can a gateway usually not do both?
    Authentication can be centralised at the edge because it needs only credentials and identity-provider state, and centralising it stops every service reimplementing credential handling. Authorization needs to know the resource - its owner, tenant and state - which the edge generally has not loaded, so anything object-level must be decided where the data is read. A gateway can enforce coarse function-level rules, but treating that as complete authorization is how record-level bugs appear.
  • Why does the design need authentication to be more than a boolean flag?
    Because policies legitimately depend on how the principal authenticated and how recently. A session hours old on an unrecognised device is not equivalent to a fresh strong authentication, and sensitive operations should be able to demand the latter. If the system stores only 'logged in', it cannot express step-up requirements and every operation inherits the weakest login it ever accepted.

saying these in an interview costs you the question

  • Defining authorization as 'checking the user is logged in'.
  • Assuming a valid session or token implies permission for whatever the request names.
  • Using shared service accounts for human actions, which satisfies policy but destroys attribution.
  • Deciding authorization once at login and caching the answer for the whole session.

context

open as a page

An endpoint returns an invoice given its identifier, and any logged-in user who supplies another customer's identifier receives their invoice. Explain why this class of defect is so common, state the enforcement rule that prevents it, and say why switching to random unguessable identifiers is not the fix.

level: middleimportance: must knowfreq 76%

basics

~20 s

Frameworks give you endpoint-level checks for free, but per-record checks need domain knowledge, so they get omitted. The rule: every request re-derives permission from server-owned state - the request says which object, never whether it is allowed. Unguessable identifiers are obscurity; identifiers leak, and then there is no check at all.

open as a page

Explain the confused-deputy problem in access control, give two examples from different layers of a system, and say what structurally prevents it rather than what patches each instance.

level: seniorimportance: must knowfreq 44%

basics

~20 s

A component with more authority than its caller performs an action the caller chose, using its own ambient authority instead of the caller's. The structural fix is to carry authority with the request - a scoped, audience-bound credential representing the original principal - rather than attaching it to the deputy's identity.

open as a page

A credential presented to a service is either a reference to state the issuer holds, or a self-contained assertion the verifier evaluates on its own. Where does the authority live in each shape, what exactly does an assertion freeze at the moment it is minted, and why does the choice between the two shapes not change what happens when the credential is stolen?

level: seniorimportance: should knowfreq 48%

basics

~20 s

A credential is either a reference to the issuer's state or a self-contained assertion the verifier evaluates alone. An assertion is a frozen authorization decision from issuance time. Both are bearer credentials — possession is authority — unless bound to a key.

open as a page

Compare role-based, attribute-based and relationship-based access control as ways to express permissions, and describe how you would choose between them for a multi-tenant product that supports sharing and delegation.

level: principalimportance: should knowfreq 42%

basics

~20 s

Roles are a closed, auditable set but explode when decisions depend on data. Attribute policies are expressive but make 'who can see this' hard to answer. Relationship models express sharing and inheritance naturally at the cost of consistency. Real systems combine: roles for coarse operations, relationships for object-level, attributes as conditions.

open as a page