Skip to main content

Identity and access

What is Authorization?

Definition

Authorization is deciding what an already-identified user or service is permitted to do — which resources it may read, change or delete.

Also known as: AuthZ, Access control

Authorization in more detail

Authorization begins where authentication ends. Once the system knows who is asking, every subsequent request needs a decision: may this identity perform this action on this object? The check is per-request and per-object, because permission is not a property of a person alone but of the pairing of a person and a thing.

Most systems express the rules in one of a few shapes. Role-based access control assigns permissions to roles and roles to users, which is simple and audits well. Attribute-based control evaluates a policy over attributes of the user, the resource and the context — department, ownership, time of day, IP range — and handles nuance that roles cannot. Relationship-based models, popularised by Google's Zanzibar, answer questions like 'is this user an editor of a document in a folder they were granted access to', which is the natural shape for sharing.

The most common real-world failure is not a broken policy but a missing check. Broken object level authorization — where an endpoint verifies you are logged in but never confirms the record belongs to you, so changing /invoices/9 to /invoices/10 returns someone else's data — has topped the OWASP API security list for years. The defence is to enforce authorization in one place the request cannot bypass, and to scope every query by owner rather than filtering afterwards.

Authorization example

Authenticated, and still refused

  GET /api/invoices/10
  Authorization: Bearer <valid token for user 12>

  invoice 10 belongs to user 77
  -> 403 Forbidden      (or 404, to avoid confirming it exists)

Enforce it in the query, not after it

  # wrong: fetch, then hope something checks
  invoice = db.find(id)

  # right: ownership is part of the lookup
  invoice = db.find(id, owner_id: current_user.id)

RBAC     viewer < editor < admin
ABAC     allow if resource.owner == user.id
         and request.time is within business hours

Authorization — common questions

Is authorization the same as authentication?
No. Authentication proves identity; authorization decides permissions for that identity. A system can authenticate you perfectly and still correctly refuse almost everything you ask it to do.
Should an unauthorized request return 403 or 404?
403 is the honest answer. Some systems return 404 for records the user may not see, so that the response does not confirm the record exists — a reasonable choice when the identifiers themselves are sensitive.
What is RBAC?
Role-based access control: permissions are attached to named roles such as viewer, editor or admin, and users receive roles. It is easy to reason about and audit, but struggles with per-object rules like 'only the document's owner', which is where attribute or relationship-based models are used.

Keep reading

Every definition in the set is indexed A-Z in the developer glossary, and the cheat sheets cover the syntax once you know what you are looking for.

Browse the A-Z glossary