What is Authorization?
Deciding whether an identified user or service may perform a specific action on a specific resource, after authentication has established who they are.
Definition
Authorization (often shortened to AuthZ) answers the question "is this caller allowed to do this to that?" It runs after authentication, which establishes identity. Every protected request carries three inputs: a subject (user, service account, API client), an action (read, update, delete, approve), and a resource (an invoice, a project, a row). An authorization check combines those with policy and returns allow or deny. In HTTP terms, a missing or invalid identity is a 401 Unauthorized, while a known identity without permission is a 403 Forbidden. Common models differ in what the policy is keyed on. Role-based access control (RBAC) grants permissions to roles such as admin or editor and assigns roles to users. Attribute-based access control (ABAC, described in NIST SP 800-162) evaluates attributes of the subject, resource, and context, such as department, document classification, or time of day. Relationship-based access control (ReBAC), popularized by Google's Zanzibar paper and implemented by OpenFGA and SpiceDB, derives permissions from a graph of relationships like "member of team that owns folder". Policy engines such as Open Policy Agent (Rego) and AWS Cedar move these rules out of application code into versioned, testable policy files. OAuth 2.0 scopes are a coarse form of delegated authorization for API clients. Authorization flaws are the most common serious web vulnerability: Broken Access Control is ranked A01 in both the OWASP Top 10 2021 and 2025, and the 2025 edition folds SSRF into it.
When to Use Authorization
Every endpoint that touches non-public data needs a server-side authorization check, including internal and "hidden" APIs. Simple RBAC is enough when permissions depend only on job function. Move to ownership checks or ReBAC when access depends on who created or shares a resource, as in multi-tenant SaaS or document sharing. ABAC or a policy engine fits when rules involve many attributes or must be audited and changed without redeploying code. Centralize checks in middleware or a single authorization service rather than scattering if-statements, but still enforce object-level checks where data is loaded. Default to deny, apply least privilege, and log denials. Hiding a button in the UI is a usability choice, not authorization.
Authorization in Practice
- An object-level check in an Express handler: the user is authenticated, but the invoice must also belong to their organization. app.get('/invoices/:id', requireAuth, async (req, res) => { const inv = await db.invoice.findUnique({ where: { id: req.params.id } }); if (!inv || inv.orgId !== req.user.orgId) return res.sendStatus(404); res.json(inv); });
- An Open Policy Agent rule that lets editors update documents only in their own department: allow if { input.action == "update" "editor" in input.user.roles input.resource.department == input.user.department }
- An OAuth access token carries scope="repo:read"; the API lets the client list repositories but returns 403 on a push because the scope lacks write permission.
- A ReBAC model in OpenFGA grants "viewer" on a folder to members of the team that owns it, so adding someone to the team automatically gives them access to every document inside.
Common Mistakes
- Checking only that the user is logged in, not that they own the requested object (IDOR). Load the resource and verify the relationship to the caller on every request.
- Enforcing permissions only in the frontend by hiding buttons or routes. Attackers call the API directly; enforce every rule on the server.
- Trusting client-supplied role or tenant IDs in request bodies or unsigned cookies. Derive identity and roles from the verified session or token.
- Defaulting to allow when no rule matches. Make deny the default so a missing rule fails closed.
- Embedding long-lived permissions in a JWT and never re-checking. Revoked roles stay active until expiry; keep tokens short-lived or check permissions server-side.