Services

Resources

Company

Authentication vs authorization (AuthN vs AuthZ)

Authentication (AuthN) answers "who are you?" by checking a credential such as a password, a passkey or a signed token. Authorization (AuthZ) answers "what may you do?" by checking that identity against rules for a specific action on a specific resource. Every request needs both, in that order.

How it works

In HTTP the two failures have different status codes. A missing or invalid token gets 401 Unauthorized, which in practice means "not authenticated". A valid token without permission gets 403 Forbidden.

Authorization models range from role-based access control (RBAC), where users get roles such as admin or viewer, to relationship-based access control (ReBAC), where access follows relationships. In a multi-tenant app, a check like can(user:pat, view, invoice:991) returns false if invoice 991 belongs to another tenant, even if Pat is an admin in their own tenant.

Why it matters in production

Most access bugs are authorization bugs: the user is who they claim to be, but one endpoint forgets to check ownership. Centralise authorization in middleware or a dedicated service, deny by default, and test every endpoint with a user from another tenant.

See also

On the One2N blog

References

  1. RFC 9110: HTTP Semantics, 401 and 403

  2. OWASP Authorization Cheat Sheet

Comic about authentication vs authorization: at the front desk Pat's ID matches and Pat gets a badge, so authentication passes; at the server room door marked IT staff only the valid badge is refused, so authorization fails; in HTTP a missing or bad token gets 401 and a valid token without permission gets 403; a per-object check returns false because Pat is in tenant A and invoice 991 belongs to tenant B.