5 concepts · 10 practice questions
Authentication establishes who is calling; authorization decides what that caller may do. The most common API flaw is a missing object-level check: the route confirms the user is signed in but not that the record asked for is theirs, so changing an id in the URL reveals someone else's data. Check ownership on the server for every request and every object, deny by default, and never trust an id or role the client sends.
def get_invoice(request, invoice_id):
user = authenticate(request) # who is calling? 401 if unknown
invoice = db.get_invoice(invoice_id)
if invoice is None or invoice.account_id != user.account_id:
raise NotFound() # may they see it? hide others' data
return invoice
Sign in to read the rest and take the 10-question test.
Sign in to continue