Skip to main content

Scopes

A scope lets a client application ask for a specific set of information about the member when it authenticates. Scopes decide which data the ID token and the access token carry.

  1. The client lists the scopes it wants in its authentication request.
  2. Keycloak validates the request and returns a token holding only the data of the scopes the client is allowed.
  3. The client reads the data and applies its own access rules.

Scopes are how the applications connected to the platform, such as a Moodle or WordPress site, receive only what they need.

Standard OpenID Connect scopes​

ScopeGives access to
openidRequired for any OpenID Connect request; returns the unique identifier sub
profileGeneral information: name, family_name, given_name, preferred_username
emailemail, email_verified
addressPostal address
phonephone_number, phone_number_verified

Open ENT scopes​

ScopeGives access to
rolesAdministrative roles: ADMIN_LOCAL, SUPER_ADMIN, CLASS_ADMIN
profilesThe member's profiles: teacher, personnel, relative, student
structuresThe member's organizations: code, name, type
groupsThe groups and classes the member belongs to
permissionsThe member's specific permissions, by role and organization
student_profileLearner data: class, options, enrollment
teacher_profileInstructor data: subjects taught, levels
relative_infoThe guardians attached to a learner

Technical scopes​

ScopeGives access to
offline_accessLong-lived refresh tokens
ent_adminThe administration interfaces
audit_logAudit and activity logs
api_accessThe platform APIs
custom_attributesCustom attributes defined for the member

A minimal client usually requests openid, profile, email and roles.

Claims by scope​

ScopeClaims in the token
openidsub
profilename, preferred_username, given_name, family_name
emailemail, email_verified
rolesrealm_access.roles, resource_access.<client>.roles
profilesrealm_access.profiles, resource_access.<client>.profiles
structuresOne entry per organization: code, name, type
groupsgroups
permissionspermissions
student_profileClass, options, enrollment
teacher_profileSubjects taught, levels
audit_loglast_login, ip_last_login, last_action
custom_attributescustom

Roles nested under organizations​

Scopes can be nested. Roles are nested under organizations, because most roles apply to one organization only:

  • SUPER_ADMIN is global: the member administers the whole platform.
  • ADMIN_LOCAL is attached to one organization.
  • CLASS_ADMIN is attached to one class.

In the example below, an instructor is in charge of class 11A in one school, where he teaches mathematics and physics, and also teaches science in a second school. The role appears only under the first organization.

{
"sub": "123456789",
"name": "John Smith",
"structures": [
{
"name": "Riverside High School",
"roles": ["CLASS_ADMIN"],
"profiles": ["teacher"],
"groups": ["Class 11A", "Class 11B"],
"permissions": ["grade_assignments"],
"teacher_profile": {
"subjects": [
{ "subject": "Mathematics", "classes": ["Class 10A", "Class 11B"] },
{ "subject": "Physics", "classes": ["Class 11B"] }
],
"main_teacher_classes": ["Class 11A"]
}
},
{
"name": "Hillside Middle School",
"roles": [],
"profiles": ["teacher"],
"groups": ["Class 7C"],
"teacher_profile": {
"subjects": [
{ "subject": "Science", "classes": ["Class 7C"] }
]
}
}
]
}

A member of the administrative staff who administers one organization:

{
"sub": "987654321",
"name": "Mary Jones",
"structures": [
{
"name": "Hillside Middle School",
"roles": ["ADMIN_LOCAL"],
"profiles": ["administrative_staff"],
"permissions": ["manage_students", "manage_teachers", "view_reports"]
}
]
}

The examples are simplified and use English key names for readability. Check the claim names in a token issued by your own platform before relying on them in a client.