Authentication and authorization
Check identity, action, and resource separately.
The idea
Authentication establishes who is calling. Authorization checks whether that identity may perform the requested action on this resource. A SaaS API should bind requests to trusted tenant membership and apply object-level checks. Deny by default when permission cannot be established.
Follow the flow
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Identity valid? → action permitted? → tenant owns resource?
Only then execute the booking operation.
Test anonymous, wrong role, wrong tenant, and valid caller.Decisions that matter
- Choose a control against a concrete risk and document its owner.
- Exercise negative cases in authorized test fixtures.
- Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A user can list their own bookings but download any attachment by ID. What failed?
Reveal a worked answer
The attachment endpoint missed object-level authorization. Apply the same trusted tenant and ownership checks to downloads, exports, and indirect IDs. Add a regression test and review sibling endpoints for the same pattern.