API gateways can centralize coarse controls, but domain services must enforce resource-level policy. Errors should help legitimate clients recover without exposing stack traces, database details, or secrets.
Exercises
Write tests for cross-user object access.
Choose limits for page size, body size, and request rate.
Design cookies for a browser session.
Self-check
What is object-level authorization?
Why rate-limit?
Why avoid detailed production errors?
Self-Check Quiz
1. Is an API gateway enough to enforce every permission?
AnswerNo. The service owning the resource must enforce its domain authorization.
2. What does CSRF exploit?
AnswerA browser's automatic credential submission to cause an unwanted state-changing request.
Homework
Design a secure API for document sharing.
Specify authorization, limits, error responses, and session policy.
Write abuse-case tests.
Sample answerEvery document operation checks the authenticated subject and document policy. Requests have bounded body and page sizes, rate limits, consistent errors, secure same-site cookies or tokens, CSRF protection where cookies are used, and tests for cross-tenant access.