Authentication and authorization
At a building’s entrance they ask for your ID to know who you are: that is authentication. Then your card opens only some floors: that is authorization, which decides what you may do.
New here? Try the first lesson without an accountHow it works
Signing in answers the first question: which account is asking. On every request, the server still has to answer the second one: whether that account may perform that action on that particular piece of data, such as reading invoice 101.
Expected behavior
Ana’s session shows who she is; a separate rule decides whether she may read invoice 101.
What can go wrong
The API treats “the session is valid” as permission to read any invoice, even one belonging to another account.
What to observe
Test with two test accounts, each with its own invoice, and write down who asked for what and what the server answered.
Common false positive
A long, hard-to-guess invoice number makes other people’s invoices harder to find, but it does not replace the permission check.
Why it matters
If the application confuses “I know who you are” with “you may do anything,” a person with an ordinary account can see or change other people’s data.
How to fix it
On every important request, the server checks three things: who is asking, what they want to do, and on which data.
Two separate questions
Authentication asks “who made this request?” Authorization asks “may that account perform this action on this data right now?” In an invoice app, the cookie answers the first question; for the second, the server checks who owns the invoice or which permissions the account has.
Data and function
Authorization can fail on data, when the API returns another account’s invoice because someone changed the number, or on a function, when an ordinary account can use a tool reserved for the site’s administrators, such as exporting every invoice. Both are tested the same way: first the normal case, then the same action with a test account that has fewer permissions. Hiding a button answers neither question.
What to write down
Write which account you used, which permissions it had, which action you tried, on which number, and what happened. “I got in” is unclear: did you see data, change something, or only receive a 200? What actually happened sets how far your conclusion goes and lets someone else repeat the test.
