Share one role check across coach class summary, notifications and lesson report
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 10/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, python
- Domain
- authorization, backend, frontend
Research direction
Start with the three permission classes in kolibri/plugins/coach/viewsets/class_summary.py, classroom_notifications.py and lesson_report.py, then compare them with KolibriAuthPermissions. The change replaces them with one coach permission class and makes the lesson report return 404 for unreadable ids. Also update the notAuthorized logic in packages/kolibri/components/pages/NotificationsRoot/index.vue. The work is done when the Context table holds for all three endpoints and the 403 assertions in their tests are replaced. The issue says it is not open for contribution, so check with maintainers before starting.
Written by the indexing model from the issue text.
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
The coach class summary, notifications and lesson report endpoints each check the coach's role with their own copy of the same code, and they disagree on status codes. The lesson report returns 403 for a lesson the user doesn't coach and 404 for one that doesn't exist, which reveals which lesson ids exist. The lesson report should rely on Lesson's read permissions, and the class summary and notifications endpoints should share one classroom role check.
Complexity: Low
Target branch: develop
Context
On #15993's head (900ae66a8e):
| class summary | notifications | lesson report | |
|---|---|---|---|
| Coach, own classroom or lesson | 200 | 200 | 200 |
| Coach, another classroom's | 403 | 403 | 403 |
| Unknown id | 403 | 403 | 404 |
| Malformed id | 403 | 403 | 404 |
| Learner | 403 | 403 | 403, or 404 for unknown or malformed |
- The three role checks:
ClassSummaryPermissions,ClassroomNotificationsPermissions,LessonReportPermissions. Lessonis readable only by an admin or coach of its collection.- Anyone in the facility can read a
Classroom.LearnerProgressNotificationis in its own database and declares no permissions, so neither endpoint can use read permissions. - The frontend checks for a timed-out session on every 403 (
client.js).NotificationsRootshowsAuthMessageonly on a 403 (index.vue).
The Change
- Lesson report: replace
LessonReportPermissionswithKolibriAuthPermissions, and addKolibriAuthPermissionsFiltertofilter_backendssoget_object()only finds readable lessons. - Class summary and notifications: replace
ClassSummaryPermissionsandClassroomNotificationsPermissionswith one coach plugin permission class that checks for a coach or admin role on the classroom. Each view tells it where its classroom id comes from: the URLpkfor class summary, theclassroom_idquery parameter for notifications. - Keep
IsAuthenticatedahead of each permission class. - Update
NotificationsRoot'snotAuthorizedto treat a 404 from these endpoints as it treats a 403.
Out of Scope
- The difficult questions endpoints, which #16069 covers.
Acceptance Criteria
- Class summary, notifications and lesson report return 404 for a classroom or lesson the user isn't a coach or admin for, including unknown and malformed ids.
- Unauthenticated requests to all three get 403.
- A coach or admin of the classroom gets the same responses as before.
- Opening Coach at
#/<class_id>/homefor a classroom the user doesn't coach shows the same message as before. - Tests cover each row of the Context table for all three endpoints, replacing their 403 assertions.
AI usage
I had Claude Code probe each endpoint's status codes on #15993's head and trace the frontend's 403 handling. I chose the scope, the shared permission class and 404 for every refused id. Claude Code drafted the sections with me.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 1.1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 87
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from learningequality/kolibri
-
Setup wizard's "Responsibilities as an administrator" step throws when left within 200 ms of openingOpenAPP: Setup Wizard bug DEV: frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
learningequality/kolibri#16097 ·
Maintainers usually reply within 1 day
-
bug DEV: frontend
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
learningequality/kolibri#16050 ·
Maintainers usually reply within 1 day
-
APP: Learn bug DEV: frontend
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
learningequality/kolibri#16096 ·
Maintainers usually reply within 1 day
-
APP: Learn bug DEV: frontend
Difficulty 4/5 3-5 days Newbie friendliness 35/100
learningequality/kolibri#16095 ·
Maintainers usually reply within 1 day
-
APP: Learn bug DEV: frontend
Difficulty 3/5 1-2 days Newbie friendliness 35/100
learningequality/kolibri#16094 ·
Maintainers usually reply within 1 day
All issues in learningequality/kolibri
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jxxghp/MoviePilot#7699 ·
Maintainers usually reply within 1 day
-
bug TAG: unit tests
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
learningequality/ricecooker#898 ·
-
next
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
j3ko/agent-plugins#80 ·
Maintainers usually reply within 1 day
-
bug:unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Heroic-Games-Launcher/HeroicGamesLauncher#6187 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
BCStudentSoftwareDevTeam/cas#491 ·
Maintainers usually reply within 8 days