See where 401 and 403 come from. In this interactive walkthrough you will tell identity, permission and ownership apart, predict 401 versus 403, and find a missing ownership check. Simulated in your browser, free, no sign-in.
Authentication & Authorization
Now simulating · step 1 of 5
Caller sends a request
Fictional learning model with invented tokens and orders. It is not a production authentication implementation and does not touch this site's sign-in.
Guided scenario: Customer A - GET /orders/ORD-101
- System believes caller is
- Customer A
- Permission required
- orders:read
- Resource owner
- ORD-101: Customer A
Tip: click a coloured area or an edge line to see what it does.
Text description of this step
- Scenario: 200: Customer A views own order. Caller believed to be: Customer A. Required permission: orders:read. Owner: Customer A.
- Client: pass. GET /orders/ORD-101 with token: demo-token-valid
Keyboard: Space plays or pauses (when not typing).
Learning objective: Tell identity, permission and ownership apart, predict 401 versus 403, and find a missing ownership check.
Step 1 · Beginner
Caller sends a request
The request carries a token that is meant to say who the caller is. Here every token is fictional.
Expected outcome: Note the identity and token state.
Sample access policy (read before running)
- Every request needs a valid token. Missing, expired or invalid tokens get 401 Unauthorized (the caller is not identified).
- Customers have orders:read. Administrators have orders:read, orders:read:any and orders:refund.
- Viewing an order needs orders:read AND the caller must own it, unless they hold orders:read:any.
- Refunding needs orders:refund (administrators only).
- A known caller without the right permission or ownership gets 403 Forbidden. Some real systems return 404 instead, to hide that the order exists.
Fictional orders
- ORD-101: owned by Customer A
- ORD-102: owned by Customer A
- ORD-201: owned by Customer B
401 vs 403 here: 401 means "we don't know who you are" (token missing, expired or invalid). 403 means "we know who you are, and you may not do this". Some real systems return 404 instead of 403 so outsiders cannot tell an order exists; follow your own API's contract.
Authentication alone is not enough: a valid token proves identity, not which records a caller may touch. Permission and ownership checks do that.
About this lesson
You will learn to
- Tell identity (authentication) apart from permission (authorization).
- Explain when this learning API returns 401 and 403.
- Find a missing ownership check and write regression tests for it.
Before you start
- Know what an API request and status code are.
Keep learning
Your progress on this topic
- Explored
- 0 of 5 guided steps viewed
- Practiced
- Not yet: Run an access check from the console
- Not yet: Reproduce the data exposure with the ownership defect switched on
- Challenges passed
- Beginner: 0 of 3 · hints 0 · wrong answers 0
- Practitioner: 0 of 3 · hints 0 · wrong answers 0
- Advanced: 0 of 2 · hints 0 · wrong answers 0
Watching the walkthrough only counts as explored. Practice needs you to use the lab yourself, and a challenge passes only when your answer meets its criteria.
Practise more
Intentional failure: Defect: the ownership check is missing
Nothing is posted anywhere. You choose where to paste the link or summary.
How to explain this in an interview
"Authentication answers who is calling; authorization answers what they may do, and ownership asks whether this record is theirs. Missing or invalid credentials give 401; a known caller without rights gives 403. My highest-value test is cross-account: a valid customer requests another customer's order, and I assert the refusal and that no foreign data appears in the body."
Progress is saved on this browser only. It is not linked to your account and other devices will not see it.
