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.
- The client lists the scopes it wants in its authentication request.
- Keycloak validates the request and returns a token holding only the data of the scopes the client is allowed.
- 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
| Scope | Gives access to |
|---|---|
openid | Required for any OpenID Connect request; returns the unique identifier sub |
profile | General information: name, family_name, given_name, preferred_username |
email | email, email_verified |
address | Postal address |
phone | phone_number, phone_number_verified |
Open ENT scopes
| Scope | Gives access to |
|---|---|
roles | Administrative roles: ADMIN_LOCAL, SUPER_ADMIN, CLASS_ADMIN |
profiles | The member's profiles: teacher, personnel, relative, student |
structures | The member's organizations: code, name, type |
groups | The groups and classes the member belongs to |
permissions | The member's specific permissions, by role and organization |
student_profile | Learner data: class, options, enrollment |
teacher_profile | Instructor data: subjects taught, levels |
relative_info | The guardians attached to a learner |
Technical scopes
| Scope | Gives access to |
|---|---|
offline_access | Long-lived refresh tokens |
ent_admin | The administration interfaces |
audit_log | Audit and activity logs |
api_access | The platform APIs |
custom_attributes | Custom attributes defined for the member |
A minimal client usually requests openid, profile, email and roles.
Claims by scope
| Scope | Claims in the token |
|---|---|
openid | sub |
profile | name, preferred_username, given_name, family_name |
email | email, email_verified |
roles | realm_access.roles, resource_access.<client>.roles |
profiles | realm_access.profiles, resource_access.<client>.profiles |
structures | One entry per organization: code, name, type |
groups | groups |
permissions | permissions |
student_profile | Class, options, enrollment |
teacher_profile | Subjects taught, levels |
audit_log | last_login, ip_last_login, last_action |
custom_attributes | custom |
Roles nested under organizations
Scopes can be nested. Roles are nested under organizations, because most roles apply to one organization only:
SUPER_ADMINis global: the member administers the whole platform.ADMIN_LOCALis attached to one organization.CLASS_ADMINis 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.