API object authorization
Identity is not permission
Authentication establishes who is requesting an operation; authorization decides whether that identity can perform it. In a bookstore, a signed-in customer may view their own order, but that does not grant access to every order. The server checks the action, object and trusted identity before returning data.
Three independent checks
Function authorization checks whether a role may use an operation, object authorization checks which record it may access, and property authorization checks which fields it may read or change. In the example, customers can read their own order status but cannot change the payment state; a support agent may read orders within an assigned tenant. Return a purpose-specific response instead of serializing every database field.
Example: decisions before data
Assume order O1 belongs to customer C1 in tenant T1. C1 can read status; C2 in T1 cannot read O1; support S1 assigned to T1 can read status; support S2 assigned to T2 cannot. None can edit payment state through the customer interface. All roles and tenant memberships come from trusted server context. Apply the same rule to nested GraphQL fields and RPC operations as relevant.
Common mistakes
A valid token, a hidden button or a hard-to-guess record identifier does not prove access is allowed. A gateway may check a token but lack current record ownership information. Enforce business authorization in the responsible service, including every relevant read and write. Consider changes to membership and ownership when caching results. A denied request must not change state or disclose private fields.
Practice: access matrix
Draw a matrix for two customers in one tenant and a support agent in another tenant. Include read status, read internal notes and edit payment state. State the default decision for an unknown role and write one legitimate allow test and three deny tests. Use fictional records only.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
API object authorization — knowledge check
Apply API security principles to fictional scenarios.
A customer is authenticated. What else is needed for an order lookup?
Which check prevents customers modifying payment state?
A support agent belongs only to tenant T2. May they read a T1 order under the example policy?
What should happen to an unrecognized role?
Why test the state after a denied write?