Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Permissions and access control

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

45 minutes

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

WordWhat it meansExample
AuthenticationProving who you are, for example with a password.Log in
AuthorisationDeciding what a person may do after they log in.May edit marks?
PlatformA system that uses data, such as a website or a phone app.The college website and the college app
PermissionSomething a person is allowed to do.Read the class marks
PrivilegeA strong permission. It gives extra power.Delete a student
Access rightThe right to read, change or delete one piece of data.Read only
RuleA condition that must be true, such as the time or the place.Only 9 to 5
RoleA job title that carries a set of permissions.Teacher
Benefit and drawbackA benefit is a good point. A drawback is a bad point.Benefit: simple. Drawback: not flexible
RBACRole-based access control. Permissions belong to roles. People get roles.All teachers can edit marks
RuBACRule-based access control. A rule decides, for example the time or place.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 in the office hours".

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

ActionStudentTeacherAdmin
Read own marksYesYesYes
Read class marksNoYesYes
Edit marksNoYesYes
Delete a studentNoNoYes

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

Code: python
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.

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

RBACRuBAC
Decides byThe role of the personA rule: time, place, device
BenefitSimple to set up. Easy to check who can do what.Flexible. Stops risky use at strange times.
DrawbackCannot 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.
ExampleTeachers can edit marks.Edit marks only from the school building.

The cells students fill in are left blank in this preview.

Quick check: RBAC or RuBAC?

Have a go

Quick check: RBAC or RuBAC?

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

The lesson goes on

3 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.