Who can open the school safe?
The school office has a safe. The head teacher can open it. The cleaner cannot. A new teacher can open it only on a weekday between 9 and 5.
Data needs the same care. A system must decide who may see marks, who may change them and who may delete them.
This lesson shows how a system decides.
Key words
| Word | What it means | Example |
|---|---|---|
| Authentication | Proving who you are. | Log in |
| Authorisation | Deciding what a person may do after they log in. | May edit marks? |
| Platform | A system that uses data. | The college website and the college app |
| Permission | Something a person is allowed to do. | Read the class marks |
| Privilege | A strong permission that gives extra power. | Delete a student |
| Access right | The right to read, change or delete one piece of data. | Read only |
| Rule | A condition about time or place that must be true. | Only 9 to 5 |
| Role | A job title that carries a set of permissions. | Teacher |
| Benefit and drawback | A good point and a bad point. | Benefit: simple. Drawback: not flexible |
| RBAC | Role-based access control: permissions belong to roles, and people get roles. | All teachers can edit marks |
| RuBAC | Rule-based access control: a rule about time or place decides. | Only from the school building |
The cells students fill in are left blank in this preview.
Five words that are easy to mix up
Authorisation is the decision. A system checks: may this person do this?
A permission is one thing they may do. A privilege is a strong permission, such as deleting data. An access right says how much: read only, or read and change.
A rule adds a condition, for example "only during office hours".
Match the word to its meaning
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Data across platforms
The same data is often used on many platforms. Marks may be on the college website, in a phone app and in a report tool.
This has a benefit. The data is kept in one place, so every platform shows the same marks. It also has a drawback. There are more doors into the data, and every door must be guarded.
So the permission check must happen on every platform, every time.
RBAC: permissions belong to roles
| Action | Student | Teacher | Admin |
|---|---|---|---|
| Read own marks | Yes | Yes | Yes |
| Read class marks | No | Yes | Yes |
| Edit marks | No | Yes | Yes |
| Delete a student | No | No | Yes |
The cells students fill in are left blank in this preview.
How RBAC works
In RBAC you do not give permissions to each person. You give them to a role. Then you give people a role.
A new teacher joins. You give them the teacher role. They get every teacher permission at once. If a teacher leaves, you remove the role.
Try it: a role table
permissions = {
"student": ["read_own_marks"],
"teacher": ["read_own_marks", "edit_marks"],
}
role = "student"
action = "edit_marks"
print(role, "may", action, "?", action in permissions[role])
# Change role to "teacher" and press Run again.
Make a free account to save your work and track your progress.
How RuBAC works
RuBAC checks a rule each time. The rule can use the time, the place or the device.
Here is an example rule. A teacher may edit marks only between 9 and 5. They must also be in the school building. The role may be right, but if the rule fails, the answer is no.
RBAC against RuBAC
| RBAC | RuBAC | |
|---|---|---|
| Decides by | The role of the person | A rule: time, place, device |
| Benefit | Simple to set up. Easy to check who can do what. | Flexible. Stops risky use at strange times. |
| Drawback | Cannot say "only on weekdays". Too many roles are hard to manage. | Rules are hard to write and test. A wrong rule stops the right person. |
| Example | Teachers can edit marks. | Edit marks only from the school building. |
The cells students fill in are left blank in this preview.
Your turn: roles and rules
A school system has three roles. Write the role check, the time rule and a function that uses both. The PERMISSIONS table is given. Press Run Tests to check your work.
PERMISSIONS = {
"student": ["read_own_marks"],
"teacher": ["read_own_marks", "read_class_marks", "edit_marks"],
"admin": ["read_own_marks", "read_class_marks", "edit_marks", "delete_student"],
}
def can_do(role, action):
# Role-based: look up the role in PERMISSIONS.
# Give back True if the role may do the action, else False.
# An unknown role may do nothing.
return None
def office_open(hour):
# Rule-based: the system works from 9 in the morning until 5 in the evening.
# hour is a whole number from 0 to 23. So 9 is open and 16 is open, but 17 is closed.
# Give back True or False.
return None
def can_access(role, action, hour):
# Both must be true: the role may do the action AND the office is open.
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Quick check: RBAC or RuBAC?
Have a go
Quick check: RBAC or RuBAC?
4 questionsKey words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Watch: roles, rules and doors
Press Play on the short film below. It follows the school safe, how roles and rules decide, and every door into the data. Listen for the myth about RBAC and RuBAC.
Film: Permissions and access control
Permissions and access control
Every scene, as text
- Who can open the school safe? The head teacher can open it (can open: yes). The cleaner cannot (can open: no). A new teacher can open it only on a weekday between 9 and 5 (can open: only at those times). Data needs the same care (a system decides: see, change or delete?).
- Key words: authentication and authorisation. First: who are you? (authentication: proving who you are). Then: what may you do? (authorisation: deciding what you may do).
- How RBAC works. A new teacher joins, with an arrow to: The teacher role (role: carries a set of permissions; benefit: simple to set up), with arrows to: Read class marks (access right: read only) and Edit marks. Delete a student: admin only (privilege: a strong permission).
- How RuBAC works. Only between 9 and 5 (rule about: the time). Only from the school building (rule about: the place). Hour 16 is open, but hour 17 is closed (the rule must be exact: closed from 17; drawback: wrong rules stop the right person).
- Data across platforms. The college website, a phone app and a report tool (drawback: each platform is a door), each joined through a check to an arrow into: Marks kept in one place (benefit: the same marks on every platform). The permission check: every platform, every time.
- Myth (false): you must pick RBAC or RuBAC. That is not true: many systems use both. The teacher role (RBAC: decides by role). On a weekday between 9 and 5 (RuBAC: decides by rule). Both must be true (so: the new teacher can open the safe).
Final check
Have a go
Final check
6 questionsRemember
Tip
Authentication is who you are. Authorisation is what you may do. RBAC decides by role. RuBAC decides by rule. Many systems use both.