Permission registry
Every resource and action the schools API will accept on a role, and the pairs it will not.
Use this page when you are adding a permission check or editing a role. It is a reference. How a request is allowed or denied is Auth & Permissions. How an admin assigns a role is Roles & Permissions Admin.
Status. Read from Naalya-API staging at a5dff0c208d5193c274d3d1f87787b55344d5d30. No role was created against a running server.
What gets generated
RESOURCE_CONFIGS in libs/shared/src/permission/permission-registry/index.ts is one object. There are no themed registry files next to it. buildRegistry() in permission.registry.ts walks that object and builds PERMISSION_REGISTRY (a flat list) and PERMISSION_REGISTRY_MAP (resource, then action).
A resource’s actions come from config.actions when that array is set. Otherwise they come from KIND_ACTIONS:
| Kind | Actions |
|---|---|
full | read, list, create, update, delete, manage |
readonly | read, list |
Action.IMPERSONATE and Action.APPROVE are enum values. They appear in the registry only when a resource lists them. Resource.ALL (all) is not a row in RESOURCE_CONFIGS.
isValidPermission accepts manage on all always. Every other pair must be in PERMISSION_REGISTRY. A role write that posts anything else fails with BadRequestException. You cannot assign impersonate through that check: no resource config includes it.
GET /api/v1/auth/permissions/registry (operationId getPermissionsRegistry) returns both shapes to a signed-in caller. It does not read the database.
Platform admin is not a registry row
AbilityFactoryService, in the UserType.PLATFORM_ADMIN branch, calls can(Action.IMPERSONATE, Resource.ALL) along with manage on school, curriculum, template, and user limited to other platform admins. That grant is built in code for the user type. It is not a permission you add on a school role.
POST /api/v1/auth/impersonate still requires impersonate on user. This page does not re-state how CASL matches all to user. Read the guard and the factory together before you change that route.
Resources
Forty-six resources are registered. String values are the enum values, not the TypeScript names.
Full kind, default six actions
user, staff, student, guardian, grade, class, application, academic_year, campus_term, role, campus, department, subject, enquiry, api_key, social_connection, job_vacancy, enrollment, transaction, payment_gateway, payment_item, school, knowledge_base, notice_board, curriculum, cbt_exam, grading_config, report_card_config, feedback, lesson_plan, template, election, library_management, calendar, school_calendar, timetable.
template’s label in the config is Templates. The resource value is still template.
Full kind, with an override
| Resource | Actions the config lists |
|---|---|
report_card | the six full actions, plus approve |
ledger | the six full actions, plus approve |
scheme_of_work | the six full actions, plus approve |
referral | read, list, create, update, manage |
referral has no delete row. A role cannot be given delete on referral.
Readonly, or a shorter list
| Resource | Actions |
|---|---|
audit_log | read, list |
analytics | read, list |
school_dashboard | read, list |
school_administration | read, list |
library_catalogue | read, list |
school_report | read, list, create |
school_report is marked kind: 'readonly' and then replaces that list with actions. The actions array is what the registry stores.
Adding a resource
- Add the value to
Resourceinpermission.enum.ts. - Add a
ResourceConfiginRESOURCE_CONFIGS. The object is typed so a missing resource fails the TypeScript build. - Grant it on the system roles that should have it.
manageonallis the separate super-admin case inisValidPermission. This pass did not re-readsystem-roles.ts.
Descriptions and tags are generated from the action and the label. Do not hand-write a description on the config.
Related pages
Roles and permissions admin
How a role is stored and assigned.
Authentication
The guards that read these pairs on a request.
Sources
Naalya-APIlibs/shared/src/permission/permission.enum.tsResource,Actionlibs/shared/src/permission/permission-registry/index.tsRESOURCE_CONFIGSlibs/shared/src/permission/permission-registry/registry.types.tsKIND_ACTIONSlibs/shared/src/permission/permission.registry.tsPERMISSION_REGISTRYlibs/shared/src/permission/permission.utils.tsisValidPermissionapps/server/src/app/auth/ability/ability-factory.service.tsUserType.PLATFORM_ADMINbranch
Auth/me and impersonation
The /auth/me contract the frontend consumes, permissions vs rules vs scope, plus platform_admin's static abilities and impersonation.
Roles and permissions admin
The management side of authorization, the permission registry, plus how roles are created, cloned, edited, and assigned to users.