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

Free lesson

6.11 (4 of 4): Permissions and access control

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

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.Log in
AuthorisationDeciding what a person may do after they log in.May edit marks?
PlatformA system that uses data.The college website and the college app
PermissionSomething a person is allowed to do.Read the class marks
PrivilegeA strong permission that gives extra power.Delete a student
Access rightThe right to read, change or delete one piece of data.Read only
RuleA condition about time or place that must be true.Only 9 to 5
RoleA job title that carries a set of permissions.Teacher
Benefit and drawbackA good point and a bad point.Benefit: simple. Drawback: not flexible
RBACRole-based access control: permissions belong to roles, and people get roles.All teachers can edit marks
RuBACRule-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

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.

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

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.

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.

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

Key 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

  1. 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?).
  2. 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).
  3. 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).
  4. 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).
  5. 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.
  6. 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 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

Remember

Tip

Authentication is who you are. Authorisation is what you may do. RBAC decides by role. RuBAC decides by rule. Many systems use both.

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.