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
