Naalya Handbook

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:

KindActions
fullread, list, create, update, delete, manage
readonlyread, 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

ResourceActions the config lists
report_cardthe six full actions, plus approve
ledgerthe six full actions, plus approve
scheme_of_workthe six full actions, plus approve
referralread, list, create, update, manage

referral has no delete row. A role cannot be given delete on referral.

Readonly, or a shorter list

ResourceActions
audit_logread, list
analyticsread, list
school_dashboardread, list
school_administrationread, list
library_catalogueread, list
school_reportread, 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

  1. Add the value to Resource in permission.enum.ts.
  2. Add a ResourceConfig in RESOURCE_CONFIGS. The object is typed so a missing resource fails the TypeScript build.
  3. Grant it on the system roles that should have it. manage on all is the separate super-admin case in isValidPermission. This pass did not re-read system-roles.ts.

Descriptions and tags are generated from the action and the label. Do not hand-write a description on the config.

Sources

  • Naalya-API libs/shared/src/permission/permission.enum.ts Resource, Action
  • libs/shared/src/permission/permission-registry/index.ts RESOURCE_CONFIGS
  • libs/shared/src/permission/permission-registry/registry.types.ts KIND_ACTIONS
  • libs/shared/src/permission/permission.registry.ts PERMISSION_REGISTRY
  • libs/shared/src/permission/permission.utils.ts isValidPermission
  • apps/server/src/app/auth/ability/ability-factory.service.ts UserType.PLATFORM_ADMIN branch

On this page