Authorization models
Understand the idea
RBAC asks for the role. ABAC asks about this user and this resource. Scopes ask what the token was issued to do.
The idea
is the job title. The matrix says editors may write notes and readers may only read them. It is easy to audit and clumsy when the rule is really this department and this clearance. ABAC looks at attributes on both sides: the user's department equals the document's department, and the clearance is high enough. Scope-based checks look at the token, not the person's whole job. A token issued with notes:read must not write, even if that person is an editor in the role matrix. The three prints are the same action asked three ways. The reader fails RBAC. The matching department passes ABAC. The read scope fails the write.
What changes
| Model | The yes looks at | Where it gets awkward |
|---|---|---|
| RBAC | The caller's role and the action | Rules like same department need a new role for every combination |
| ABAC | Attributes of the user and of this resource | The rule is harder to read and easier to get half-wrong |
| Scopes | The list on this token | A wide role and a narrow token disagree unless you check the token |
The command
Reader, department, and scope
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The mistake
Check the result
rbac is false for a reader writing. abac is true when department and clearance match. scope is false when the token only has notes:read.
Guided challenge
Use the role matrix
rbac currently returns true for every known role, so a reader can write. Check the action against that role's list.
Use the role matrix
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
rbac false abac true scope false
Hints 0/2
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 150 XP. You can always revisit it.