These are the notes for Cybersecurity Fundamentals (defensive), episode 30. Episodes 28 and 29 made sure we know who is logged in. Today's question: what are they allowed to do? We start with simple if-statements, break them, and invent every major model on the way: authorization and access control, subject, object and action, ACLs (access control lists), DAC (discretionary access control), MAC (mandatory access control) with labels and clearances, capabilities, RBAC (role-based access control) and privilege creep, ABAC (attribute-based access control), ReBAC (relationship-based access control) and Google Zanzibar, the PDP (policy decision point) and PEP (policy enforcement point), deny by default, and policy as code with Open Policy Agent. Every term is explained the first time it appears, and the Glossary at the end defines them all again.
Ravi, Neha, Meera, Kabir, Arjun, Asha, every file, store and amount here are made up, and everything runs locally on toy data. Every code sample runs with Python 3.13 (standard library only); outputs are real, copied from actual runs.
The problems you'll solve
| Problem | Idea it teaches |
|---|---|
| Who may open which door? | Authorization, access control, subject, object, action |
| Permissions as names in if-statements | Why rules must live outside scattered code |
| A list on each object; the owner shares payroll with an intern | ACL, DAC |
| Rules owners can't override | MAC, labels, clearances, no read up, no write down |
| Guest list or ticket? | ACLs vs capabilities |
| 5,000 people, 300 apps | RBAC, roles, privilege creep, access reviews |
| "Own store, up to Rs 5,000, store hours, company laptop" | ABAC, role explosion |
| Shared folders and groups | ReBAC, relationship tuples, Google Zanzibar |
| The same rule copied into every endpoint | PDP, PEP, deny by default |
| Policies that can be reviewed and tested | Policy as code, Open Policy Agent, Rego |
Problem 1: what authorization is
Doors in an office
| Office | Software | Term |
|---|---|---|
| Priya, who already proved who she is | The logged-in user, or a program | Subject |
| The server room door | A file, an order, a page, an API | Object (or resource) |
| Open the door | read, write, delete, approve | Action |
| The door opens or stays shut, every time | allow or deny, on every request | Access control |
Authorization is the decision: may this subject do this action on this object? Access control is the whole system that makes and enforces those decisions. Authentication (episodes 28-29) happens at login; authorization happens on every request.
Demo 1: the obvious way, names in if-statements
# The obvious way: permission checks written as if-statements, scattered through the code
def can_view_payroll(user):
return user in ("ravi", "neha") # finance team, as of January
def can_edit_prices(user):
return user in ("ravi", "arjun")
def can_export_payroll(user): # written later, by someone else
return user in ("ravi", "neha", "kabir") # kabir moved to sales in March...
# April: Meera joins finance. Someone updates ONE function and forgets the other.
def can_view_payroll(user): return user in ("ravi", "neha", "meera")
for user in ["meera", "kabir"]:
print(f"{user:6} view={can_view_payroll(user)!s:5} export={can_export_payroll(user)}")
Output:
meera view=True export=False
kabir view=False export=True
(Redefining can_view_payroll simply replaces the old function, the way an edit in one file of a big codebase would. !s:5 prints the boolean as text, padded to 5 characters.)
Two bugs from one ordinary week: the new hire can view but not export, and the person who left finance can still export the whole payroll. Why? The rules are copied into many places, mixed with code, and nobody can see who has access to what.
Problem 2: a list on each object (ACLs and DAC)
An access control list (ACL) is attached to one object and says who may do what with it: payroll.xlsx: neha → read, write. Linux file permissions (episode 9) are a small, fixed-format ACL.
Who edits the list? In discretionary access control (DAC), the object's owner does, at their discretion (their own choice). That's how sharing works on your laptop and in most file-sharing apps.
Demo 2: the owner shares with anyone
# DAC (discretionary): every file keeps its own list, an ACL, and its OWNER decides who's on it
files = {"payroll.xlsx": {"owner": "neha", "acl": {"neha": {"read", "write"}}}}
def share(file, by, to, rights):
if files[file]["owner"] != by: return f"{by} is not the owner of {file}"
files[file]["acl"][to] = set(rights); return f"{by} shared {file} with {to}: {sorted(rights)}"
def can(user, right, file): return right in files[file]["acl"].get(user, set())
print(share("payroll.xlsx", "kabir", "kabir", ["read"])) # a non-owner can't
print(share("payroll.xlsx", "neha", "intern", ["read"])) # the owner can share with ANYONE
print("intern can read payroll:", can("intern", "read", "payroll.xlsx"))
Output:
kabir is not the owner of payroll.xlsx
neha shared payroll.xlsx with intern: ['read']
intern can read payroll: True
The rule worked exactly as designed, and the intern can read every salary. Why it's a problem: with DAC, security depends on every owner's judgement, one mistake (or one phished owner) at a time.
Problem 3: the system decides (MAC)
In an army office, the security office stamps every file PUBLIC, CONFIDENTIAL or SECRET, officers are cleared to a level after background checks, and nobody can hand a secret file to someone without clearance, even if they hold the copy.
Mandatory access control (MAC): the system assigns each object a label (a sensitivity level) and each subject a clearance (the highest level they may read), and enforces the rules; owners cannot override them. Two classic rules, from the Bell-LaPadula confidentiality model:
- No read up (the simple security property): read only data at or below your clearance.
- No write down (the star property): don't write into objects with a lower label, so secrets can't be copied downward.
Demo 3: labels and clearances
# MAC (mandatory): the SYSTEM labels data and clears people; owners cannot override it
LEVEL = {"public": 0, "internal": 1, "confidential": 2, "secret": 3}
clearance = {"intern": "internal", "neha": "confidential", "ceo": "secret"}
label = {"menu.pdf": "public", "payroll.xlsx": "confidential", "merger.docx": "secret"}
def can_read(user, file): # "no read up": only data at or below your clearance
return LEVEL[clearance[user]] >= LEVEL[label[file]]
def can_write(user, file): # "no write down": can't copy secrets into lower files
return LEVEL[clearance[user]] <= LEVEL[label[file]]
for user in ["intern", "neha", "ceo"]:
print(f"{user:6}", {f: can_read(user, f) for f in label})
print("neha copies payroll into menu.pdf? write allowed:", can_write("neha", "menu.pdf"))
Output:
intern {'menu.pdf': True, 'payroll.xlsx': False, 'merger.docx': False}
neha {'menu.pdf': True, 'payroll.xlsx': True, 'merger.docx': False}
ceo {'menu.pdf': True, 'payroll.xlsx': True, 'merger.docx': True}
neha copies payroll into menu.pdf? write allowed: False
MAC is very strong but rigid: every object needs a label and every person a clearance. It's used where confidentiality matters most (governments, defence) and inside some hardened operating systems.
ACLs vs capabilities
| At an event | Model | Who holds the permission? | Good at | Weak at |
|---|---|---|---|---|
| A guest list at the door; the door checks your name | ACL | The object holds a list of subjects | Auditing: see everyone with access | Delegating quickly |
| A cinema ticket; whoever holds it gets in | Capability | The subject holds an unforgeable token | Delegating: hand it on | Revoking: hard to take back once copied |
A capability is a token that itself grants a right, so it must be unforgeable: a share link with a long random key, or a signed token. The tokens of episode 31 (JWT) are capabilities, so the revocation problem comes back there.
Problem 4: roles (RBAC) and privilege creep
Ravi's company grows to 5,000 people and 300 apps. Listing every person on every object means millions of entries; every new hire needs dozens of edits and someone always misses one; every leaver must be found on every list.
Role-based access control (RBAC) adds a middle layer: permissions are given to roles (like finance), and people are given roles. A new hire gets one role and has everything for the job; a leaver loses their roles and loses everything. RBAC was introduced in 1992 by Ferraiolo and Kuhn at NIST as "a general-purpose role based access control model", and adopted as the US national standard ANSI/INCITS 359-2004 on 11 February 2004 (NIST CSRC).
users ──has──▶ roles ──grants──▶ permissions
neha, meera finance payroll:view, payroll:export
Demo 4: roles, a mover, and an access review
# RBAC: permissions go to ROLES; people get roles. Change a role once, everyone updates.
ROLES = {"finance": {"payroll:view", "payroll:export"},
"sales": {"prices:view", "orders:create"},
"pricing": {"prices:view", "prices:edit"}}
user_roles = {"neha": {"finance"}, "meera": {"finance"}, "kabir": {"finance"}}
def can(user, permission):
return any(permission in ROLES[r] for r in user_roles.get(user, set()))
print("meera export payroll:", can("meera", "payroll:export")) # new hire: one role, done
user_roles["kabir"].add("sales") # March: Kabir MOVES to sales...
print("kabir roles:", sorted(user_roles["kabir"]), "| export payroll:", can("kabir", "payroll:export"))
user_roles["kabir"] = {"sales"} # the fix: a mover's old roles are REMOVED
print("after access review:", sorted(user_roles["kabir"]), "| export payroll:",
can("kabir", "payroll:export"))
Output:
meera export payroll: True
kabir roles: ['finance', 'sales'] | export payroll: True
after access review: ['sales'] | export payroll: False
Privilege creep is collecting more and more permissions as you move between jobs, because new roles are added and old ones are never removed. Fixes:
- Joiner-mover-leaver processes: when someone moves, remove old roles, don't just add new ones; when they leave, remove everything (episode 34).
- Access reviews (recertification): managers regularly confirm who still needs what.
- Least privilege (episode 3): each role carries only what the job needs.
Problem 5: attributes (ABAC)
Asha manages the Pune store. A role says she's a store manager, but the real rule is: refunds only for her own store, up to Rs 5,000, during store hours, from a company laptop. With roles alone you'd need a role for every store × limit × time: role explosion.
Attribute-based access control (ABAC) decides from attributes: facts about the user (role, store, department), the resource (its store, amount, owner, sensitivity) and the environment (time, location, device).
Demo 5: one rule, five decisions
# ABAC: decide from ATTRIBUTES of the user, the resource and the environment
def can_approve_refund(user, refund, env):
return (user["role"] == "store_manager"
and user["store"] == refund["store"] # only her own store
and refund["amount"] <= 5000 # up to Rs 5,000
and 9 <= env["hour"] < 21 # during store hours
and env["device_managed"]) # from a company device
asha = {"role": "store_manager", "store": "Pune"}
tests = [("own store, Rs 1,200, 2 PM", {"store": "Pune", "amount": 1200}, 14, True),
("other store", {"store": "Delhi", "amount": 1200}, 14, True),
("Rs 9,000", {"store": "Pune", "amount": 9000}, 14, True),
("own store, 11 PM", {"store": "Pune", "amount": 1200}, 23, True),
("personal laptop", {"store": "Pune", "amount": 1200}, 14, False)]
for name, refund, hour, managed in tests:
ok = can_approve_refund(asha, refund, {"hour": hour, "device_managed": managed})
print(f"{name:27} -> {'ALLOW' if ok else 'deny'}")
Output:
own store, Rs 1,200, 2 PM -> ALLOW
other store -> deny
Rs 9,000 -> deny
own store, 11 PM -> deny
personal laptop -> deny
ABAC is very expressive but harder to read and test ("which of ten conditions failed?"). Many systems mix both: roles for the broad strokes, attributes for the fine print (the mini project below does exactly that, and explains its decisions).
Problem 6: relationships (ReBAC) and Google Zanzibar
In a document app, Neha is an editor of the Q3 folder, the whole finance group can view it, and a budget document inside should inherit that sharing. When Meera joins the finance group, she should see the document at once. Access follows relationships: owner of, member of, inside of.
Relationship-based access control (ReBAC) stores facts as relationship tuples (object, relation, subject) and answers a check by following links between them. A subject can also be a set, like group:finance#member ("everyone who is a member of group:finance").
Demo 6: following tuples
# ReBAC: permissions follow RELATIONSHIPS, stored as tuples: (object, relation, subject)
tuples = {("folder:q3", "editor", "user:neha"),
("folder:q3", "viewer", "group:finance#member"), # everyone in the finance group
("group:finance", "member", "user:meera"),
("doc:budget", "parent", "folder:q3")} # the doc lives in the folder
def check(obj, relation, user):
if (obj, relation, user) in tuples: return True
if relation == "viewer" and check(obj, "editor", user): return True # editors can view
for o, r, s in tuples:
if o == obj and r == relation and "#" in s: # a group of users
group, rel = s.split("#")
if check(group, rel, user): return True
if o == obj and r == "parent": # inherit from folder
if check(s, relation, user): return True
return False
for user, rel in [("user:neha", "editor"), ("user:meera", "viewer"), ("user:meera", "editor"),
("user:kabir", "viewer")]:
print(f"{user:10} {rel:6} doc:budget -> {check('doc:budget', rel, user)}")
Output:
user:neha editor doc:budget -> True
user:meera viewer doc:budget -> True
user:meera editor doc:budget -> False
user:kabir viewer doc:budget -> False
Nobody wrote an entry for the document itself: Neha edits it through the folder; Meera views it through the group and the folder; Kabir isn't connected at all. (The toy check has no cycle protection; real systems limit the depth of the search.)
Google Zanzibar. Google described its global authorization system in the USENIX ATC 2019 paper "Zanzibar: Google's Consistent, Global Authorization System". It stores relationship tuples like these, "scales to trillions of access control lists and millions of authorization requests per second", serves "hundreds of client services at Google, including Calendar, Cloud, Drive, Maps, Photos, and YouTube", and has kept 95th-percentile latency under 10 milliseconds with availability above 99.999% over 3 years of production use. Open-source systems inspired by it do the same for other companies.
Comparing the models
| Model | Who decides | Based on | Strength | Weakness | Typical use |
|---|---|---|---|---|---|
| ACL / DAC | The object's owner | A list on each object | Flexible, simple sharing | Owners overshare; hard to audit at scale | File sharing, laptops |
| MAC | The system | Labels and clearances | Very strong, can't be overridden | Rigid, heavy to administer | Government, defence, hardened OS |
| Capabilities | Whoever holds the token | Unforgeable tokens | Easy delegation | Hard revocation | Share links, signed tokens |
| RBAC | Administrators | Roles | Easy joiners/leavers, auditable | Role explosion, privilege creep | Most company apps |
| ABAC | Policy authors | Attributes of user, resource, environment | Very expressive, context-aware | Harder to understand and test | Fine-grained, contextual rules |
| ReBAC | Relationship data | Tuples and links | Natural for sharing, groups, hierarchies | Graph checks must be fast | Docs, folders, social apps |
Problem 7: one judge, many doors
Whatever the model, our very first demo had one more lesson: don't copy rules into every function. Split the work:
- A policy enforcement point (PEP) sits at each door (each endpoint, API gateway or service). It stops the request, asks for a decision, and enforces it.
- A policy decision point (PDP) is one shared engine that evaluates the policy and answers allow or deny.
request ──▶ PEP (the door: enforces) ──asks──▶ PDP (the judge: decides) ◀── policy
Change a rule once in the PDP, and every door obeys. The PDP also needs a safe answer for requests no rule mentions.
Demo 7: allow by default vs deny by default
# One place decides (PDP); every endpoint asks it and obeys (PEP). Policy is plain data.
POLICY = {("finance", "payroll:view"): "allow",
("sales", "prices:view"): "allow",
("intern", "payroll:view"): "deny"}
def decide(role, action, default): # the Policy Decision Point
return POLICY.get((role, action), default)
def endpoint(role, action, default): # a Policy Enforcement Point
return f"{role:7} {action:15} -> {'200' if decide(role, action, default) == 'allow' else '403'}"
# a developer adds a NEW endpoint, "payroll:delete", and forgets to write a rule for it
for default in ("allow", "deny"):
print(f"default={default}:")
for role, action in [("finance", "payroll:view"), ("sales", "payroll:view"),
("intern", "payroll:delete")]:
print(" ", endpoint(role, action, default))
Output:
default=allow:
finance payroll:view -> 200
sales payroll:view -> 200
intern payroll:delete -> 200
default=deny:
finance payroll:view -> 200
sales payroll:view -> 403
intern payroll:delete -> 403
Deny by default: no matching rule means no access. Every forgotten rule then fails safe (a confused user asks for access) instead of failing open (a data leak). It's fail secure from episode 3, and the firewall's default deny from episode 24.
Policy as code
Policy as code means writing the authorization policy in its own files, separate from the application, so it can be reviewed, kept in version control (git) and tested automatically, like any other code.
A well-known engine is Open Policy Agent (OPA): "an open source, general-purpose policy engine" (CNCF) that acts as a PDP. You write rules in its policy language, Rego; OPA "bases decisions on input data, a Rego policy, and optionally external data" (OPA blog) and returns a decision. OPA joined the Cloud Native Computing Foundation (CNCF, a foundation that hosts many open-source cloud projects) as a sandbox project in April 2018 and became a graduated project on 4 February 2021.
The next problem
Decisions now come from one place and say no by default. But Ravi's app becomes twenty small services, and each must know who's calling and what they may do, without asking the login server every time. The answer is a signed ticket, a capability: the token. Episode 31: tokens and JWT done safely.
The whole chain
- Scattered if-statements → access control as its own system.
- A list on each object → ACLs; the owner decides → DAC.
- Owners overshare → MAC: labels, clearances, no read up, no write down.
- Guest list vs ticket → ACLs vs capabilities.
- Too many pairs → RBAC; movers → privilege creep, access reviews.
- Rules roles can't say → ABAC; shared folders → ReBAC (Zanzibar).
- Rules copied everywhere → one PDP with PEPs, deny by default, policy as code.
...and you just invented modern authorization.
Common mistakes (and what they print)
| Mistake | What you see | Why it's wrong | Fix |
|---|---|---|---|
| Names hard-coded in if-statements | kabir view=False export=True |
Rules copied and forgotten | Roles + one decision point |
| Owners share sensitive data freely | intern can read payroll: True |
DAC trusts every owner | Labels / MAC or org-wide policy for sensitive data |
| Movers only gain roles | kabir roles: ['finance', 'sales'] |
Privilege creep | Remove old roles; access reviews |
| Allow by default | intern payroll:delete -> 200 |
A missing rule allowed it | Deny by default |
| A lookup that crashes on unknown users | KeyError: 'kabir' |
Unknown subjects are normal input; a crash may fail open or become a 500 | .get(...) with a deny result |
| Checking permissions only in the UI | Hidden button, but the API still works | The client can't be trusted (episode 28) | Check on the server, in every endpoint (episode 37) |
| One giant "admin" role | Everyone ends up admin | No least privilege | Small, job-sized roles |
| Thousands of near-identical roles | Pune_5000_day, Delhi_5000_day ... |
Role explosion | Add attributes (ABAC) |
Mini project: Ravi's tiny policy engine
A small PDP that combines roles (RBAC), attribute conditions (ABAC) and deny by default, and explains every denial.
# Ravi's tiny policy engine: roles + attribute conditions + deny by default, and it explains itself
ROLES = {"finance": {"payroll:view", "payroll:export"}, "store_manager": {"refund:approve"},
"auditor": {"payroll:view"}}
CONDITIONS = { # extra attribute rules per permission
"payroll:export": [("company device", lambda u, r, e: e["device_managed"])],
"refund:approve": [("own store", lambda u, r, e: u["store"] == r["store"]),
("<= Rs 5,000", lambda u, r, e: r["amount"] <= 5000),
("store hours", lambda u, r, e: 9 <= e["hour"] < 21)],
}
def decide(user, permission, resource={}, env={}):
if not any(permission in ROLES.get(role, set()) for role in user["roles"]):
return "DENY (no role grants " + permission + ")" # deny by default
for name, rule in CONDITIONS.get(permission, []):
if not rule(user, resource, env): return f"DENY (failed: {name})"
return "ALLOW"
neha = {"roles": {"finance"}}
asha = {"roles": {"store_manager"}, "store": "Pune"}
audit = {"roles": {"auditor"}}
print("neha export, laptop :", decide(neha, "payroll:export", env={"device_managed": True}))
print("neha export, own PC :", decide(neha, "payroll:export", env={"device_managed": False}))
print("auditor export :", decide(audit, "payroll:export", env={"device_managed": True}))
print("asha refund 1,200 :", decide(asha, "refund:approve", {"store": "Pune", "amount": 1200}, {"hour": 14}))
print("asha refund, Delhi :", decide(asha, "refund:approve", {"store": "Delhi", "amount": 1200}, {"hour": 14}))
print("asha payroll:delete :", decide(asha, "payroll:delete"))
Output:
neha export, laptop : ALLOW
neha export, own PC : DENY (failed: company device)
auditor export : DENY (no role grants payroll:export)
asha refund 1,200 : ALLOW
asha refund, Delhi : DENY (failed: own store)
asha payroll:delete : DENY (no role grants payroll:delete)
Ideas to extend it: log every decision with the reason (an audit trail, episode 48); load ROLES and CONDITIONS from a JSON file (policy as code); write unit tests that assert each decision.
Practice
1. A pricing user. Give Arjun the pricing role in Demo 4. Can he edit prices? View payroll?
Solution
ROLES = {"finance": {"payroll:view", "payroll:export"},
"sales": {"prices:view", "orders:create"},
"pricing": {"prices:view", "prices:edit"}}
user_roles = {"neha": {"finance"}, "arjun": {"pricing"}}
def can(user, permission):
return any(permission in ROLES[r] for r in user_roles.get(user, set()))
print("arjun edit prices:", can("arjun", "prices:edit"))
print("arjun view payroll:", can("arjun", "payroll:view"))
arjun edit prices: True
arjun view payroll: False
2. No Sunday refunds. Add an environment attribute weekday to Demo 5 and deny refunds on Sundays.
Solution
def can_approve_refund(user, refund, env):
return (user["role"] == "store_manager" and user["store"] == refund["store"]
and refund["amount"] <= 5000 and 9 <= env["hour"] < 21
and env["device_managed"] and env["weekday"] != "Sunday") # new: no Sunday refunds
asha = {"role": "store_manager", "store": "Pune"}
for day in ("Saturday", "Sunday"):
env = {"hour": 14, "device_managed": True, "weekday": day}
print(day, "->", can_approve_refund(asha, {"store": "Pune", "amount": 1200}, env))
Saturday -> True
Sunday -> False
One new attribute, no new roles: that's ABAC's strength.
3. Editor of one document only. In Demo 6, make Meera an editor of doc:budget but not of the folder.
Solution
tuples = {("folder:q3", "editor", "user:neha"),
("folder:q3", "viewer", "group:finance#member"),
("group:finance", "member", "user:meera"),
("doc:budget", "parent", "folder:q3"),
("doc:budget", "editor", "user:meera")} # new: Meera edits this one doc only
def check(obj, relation, user):
if (obj, relation, user) in tuples: return True
if relation == "viewer" and check(obj, "editor", user): return True
for o, r, s in tuples:
if o == obj and r == relation and "#" in s:
group, rel = s.split("#")
if check(group, rel, user): return True
if o == obj and r == "parent":
if check(s, relation, user): return True
return False
print("meera editor doc:budget ->", check("doc:budget", "editor", "user:meera"))
print("meera editor folder:q3 ->", check("folder:q3", "editor", "user:meera"))
meera editor doc:budget -> True
meera editor folder:q3 -> False
Adding one tuple was enough; permissions flow down from folders to documents, not up.
4. Pick the model. (a) A hospital: doctors read records only of patients in their ward during their shift. (b) Military files with Secret/Top Secret stamps. (c) A shared drive with folders and groups. (d) A company app where staff get access by job title.
Solution
(a) ABAC (ward, shift, device). (b) MAC (labels and clearances). (c) ReBAC (folders, groups, inheritance). (d) RBAC (roles by job).
5. ACL or capability? (a) A share link with a long random key. (b) A file's "shared with" list. (c) A signed token that says "may read order 5521 until 6 PM".
Solution
(a) Capability: holding the link grants access. (b) ACL: the object holds the list. (c) Capability: the subject carries the signed right; it can't easily be revoked before 6 PM (episode 31 deals with that).
Quick quiz
"A doctor may read a patient's record only if the patient is in the doctor's own ward, during the doctor's shift, from a hospital computer." Which model fits best?
- A: DAC
- B: MAC
- C: RBAC
- D: ABAC
Answer
D, ABAC. The rule depends on attributes of the user (ward, shift), the resource (the patient's ward) and the environment (time, device). Roles alone would explode into one role per ward per shift; ABAC expresses it in one rule.
Interview questions
- Authentication vs authorization? Authentication proves who you are; authorization decides what you may do, on every request.
- What is an ACL? A list attached to an object naming which subjects may perform which actions on it.
- DAC vs MAC? In DAC the owner decides who gets access; in MAC the system enforces labels and clearances that owners cannot override.
- What are "no read up" and "no write down"? Bell-LaPadula's confidentiality rules: read only at or below your clearance; don't write into lower-labelled objects, so secrets can't leak downward.
- ACLs vs capabilities? ACLs live on the object (easy to audit); capabilities are unforgeable tokens held by subjects (easy to delegate, hard to revoke).
- Explain RBAC and its main risk. Permissions are assigned to roles, roles to users. Main risks: privilege creep (movers accumulate roles) and role explosion; mitigate with joiner-mover-leaver processes and access reviews.
- When would you choose ABAC over RBAC? When decisions depend on context: resource ownership, amounts, time, location, device. Usually combined with RBAC.
- What is ReBAC? Give an example system. Authorization from relationships stored as tuples (object, relation, subject), with inheritance through groups and hierarchies; Google Zanzibar, which serves Drive, YouTube and other Google services.
- What are a PDP and a PEP? The PDP evaluates policy and returns allow/deny; the PEP intercepts requests, asks the PDP and enforces its answer.
- Why deny by default? A missing or mistaken rule then fails safe (access denied) instead of failing open (data exposed).
- What is policy as code? Writing authorization policy as versioned, reviewed, tested files separate from application code, evaluated by an engine such as Open Policy Agent (Rego).
Glossary
| Term | Meaning in plain words | Example |
|---|---|---|
| Authorization | Deciding whether a subject may do an action on an object | May Kabir export payroll? |
| Access control | The whole system that makes and enforces authorization decisions | Roles + PDP + PEPs |
| Subject | Who is asking: a user or a program | neha |
| Object / resource | What is being protected | payroll.xlsx |
| Action | What the subject wants to do | read, export, approve |
| ACL | Access control list: who may do what, attached to one object | payroll.xlsx: neha → read, write |
| DAC | Discretionary access control: the owner decides | Neha shares with the intern |
| MAC | Mandatory access control: the system enforces labels and clearances | Secret files in an army office |
| Label | The sensitivity level assigned to an object | confidential |
| Clearance | The highest level a subject may read | neha: confidential |
| Bell-LaPadula | A classic confidentiality model behind MAC | No read up, no write down |
| No read up | Read only data at or below your clearance | The intern can't read payroll |
| No write down | Don't write into lower-labelled objects | Payroll can't go into menu.pdf |
| Capability | An unforgeable token that itself grants a right | A share link, a signed token |
| RBAC | Role-based access control: permissions → roles → users | finance role |
| Role | A named bundle of permissions for a job | pricing |
| Permission | One allowed action on one kind of object | payroll:export |
| Privilege creep | Accumulating permissions over time, especially when moving jobs | Kabir keeps finance |
| Joiner-mover-leaver | The process of granting, changing and removing access as people join, move and leave | Remove old roles on a move |
| Access review / recertification | Managers regularly confirming who still needs what | "Does Kabir still need finance?" |
| Least privilege | Give only the access the job needs (episode 3) | Small roles |
| Role explosion | Needing a huge number of roles to express fine rules | Pune_5000_day ... |
| ABAC | Attribute-based access control: decisions from user, resource and environment attributes | Demo 5 |
| Attribute | A fact about a user, resource or environment | store, amount, hour, device |
| ReBAC | Relationship-based access control: decisions from relationships | Demo 6 |
| Relationship tuple | A stored fact (object, relation, subject) |
("folder:q3", "editor", "user:neha") |
| Google Zanzibar | Google's global ReBAC authorization system (USENIX ATC 2019) | Drive, YouTube, Calendar |
| PDP | Policy decision point: evaluates policy, returns allow/deny | decide() |
| PEP | Policy enforcement point: intercepts requests and enforces the decision | endpoint() |
| Deny by default | No matching rule means no access | default="deny" |
| Fail secure / fail open | On error, deny / on error, allow (episode 3) | 403 vs 200 for a forgotten rule |
| Policy as code | Policies written as versioned, reviewed, tested files | OPA policies in git |
| Open Policy Agent (OPA) | An open-source, general-purpose policy engine | A shared PDP |
| Rego | OPA's policy language | Rules OPA evaluates |
| CNCF | Cloud Native Computing Foundation, home of many cloud open-source projects | OPA graduated 4 Feb 2021 |
Summary
- Authorization decides what an authenticated subject may do to an object, on every request; access control is the system around it.
- Scattered if-statements drift: move rules out of the code.
- ACLs / DAC: lists on objects, owners decide (flexible, but owners overshare). MAC: labels and clearances the system enforces (no read up, no write down).
- ACLs live on the object; capabilities are tokens in the subject's hand.
- RBAC (Ferraiolo and Kuhn, NIST 1992; ANSI standard 2004) groups permissions into roles; watch for privilege creep and run access reviews.
- ABAC adds context (store, amount, time, device); ReBAC follows relationships (Google Zanzibar: trillions of ACLs, millions of checks per second).
- Put decisions in one PDP, enforce at every PEP, deny by default, and manage policy as code (Open Policy Agent, Rego; CNCF graduated 4 Feb 2021).
Next episode: tokens and JWT done safely: bearer tokens, opaque vs self-contained tokens, JWT structure and claims, HS256 vs RS256 vs ES256, alg=none and algorithm confusion, JWKS, expiry, revocation, refresh tokens and token storage in browsers.
Sources: NIST CSRC, "Role Based Access Control FAQ"; Pang et al., "Zanzibar: Google's Consistent, Global Authorization System", USENIX ATC 2019 (abstract); CNCF (4 Feb 2021), "Cloud Native Computing Foundation Announces Open Policy Agent Graduation"; Open Policy Agent blog. Code outputs from Python 3.13. Fetched 4 Nov 2026.